/* =====================================================================
   Ishan Bhatt — site styles
   Colors and fonts are defined once here; change them and the whole
   site follows.
   ===================================================================== */

:root {
  --bg:           #FAF8F4;   /* off-white page */
  --text:         #474D4B;   /* body text, soft charcoal */
  --heading:      #1F2422;   /* headings */
  --muted:        #7D8481;   /* dates, captions, meta */
  --rule:         #E6E2D9;   /* hairlines */
  --rule-strong:  #CFC9BD;   /* heavier hairlines under section titles */
  --accent:       #8B2E2A;   /* links, a muted Harvard crimson */
  --accent-hover: #5F1C18;
  --accent-soft:  rgba(139, 46, 42, 0.32);
  --tint:         #F2EFE8;   /* code / subtle panels */
  --frame:        #DDD8CE;   /* photo border, abstract rule */
  --selection:    #EBDDD3;

  --serif: "EB Garamond", Garamond, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --wrap:    900px;          /* page width */
  --measure: 680px;          /* comfortable reading width (bio, essays) */
}

/* White version. Turn it on or off with `background:` in _config.yml. */
:root[data-theme="white"] {
  --bg:          #FFFFFF;
  --rule:        #E7E7E4;
  --rule-strong: #CDCDC8;
  --tint:        #F4F4F2;
  --frame:       #DCDCD8;
  --selection:   #EEE2DC;
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 350;          /* a touch lighter than regular */
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--accent-soft);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

::selection { background: var(--selection); color: var(--heading); }

.skip-link {
  position: absolute; left: 16px; top: -48px;
  background: var(--bg); padding: 8px 12px; z-index: 10;
}
.skip-link:focus { top: 12px; }

.wrap {
  max-width: calc(var(--wrap) + 48px);
  margin: 0 auto;
  padding: 0 24px;
}

.sep { margin: 0 0.5em; color: var(--rule-strong); }

/* Small UI text stays at regular weight so it remains crisp. */
.site-nav, .site-footer,
.entry__date, .eyebrow, .page-research h3 + p, .prose summary, .prose small,
.prose .footnotes, .essay__footer { font-weight: 400; }

/* ---------- Header ---------- */

.site-header__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 32px;
  padding: 30px 0 18px;
  border-bottom: 1px solid var(--rule);
}

.site-name {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.2;
  color: var(--heading);
  text-decoration: none;
  letter-spacing: 0.005em;
}
.site-name:hover { color: var(--accent); }

.site-nav { display: flex; gap: 26px; }
.site-nav a {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}
.site-nav a:hover { color: var(--heading); }
.site-nav a[aria-current="page"] {
  color: var(--heading);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 0.45em;
}

.site-main { padding: 56px 0 88px; }

/* ---------- Footer ---------- */

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 22px 0 44px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}
.site-footer__inner p { margin: 0; }
.site-footer__links { display: flex; gap: 20px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--heading); }

/* ---------- Headings & prose ---------- */

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--heading);
}

.page-header { margin-bottom: 44px; }
.page-title {
  margin: 0;
  font-size: 48px;
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.page-subtitle, .page-intro {
  margin: 14px 0 0;
  max-width: var(--measure);
  color: var(--text);
}
.page-intro > :last-child { margin-bottom: 0; }

.section-title {
  margin: 0 0 22px;
  padding-bottom: 14px;
  font-size: 30px;
  line-height: 1.2;
  border-bottom: 1px solid var(--rule-strong);
}

.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose table, .prose pre { margin: 0 0 1.2em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.3em 0; }
.prose li::marker { color: var(--muted); }

.prose h2 {
  margin: 2.4em 0 0.8em;
  padding-bottom: 0.45em;
  font-size: 30px;
  line-height: 1.2;
  border-bottom: 1px solid var(--rule-strong);
}
.prose h3 { margin: 1.9em 0 0.5em; font-size: 24px; line-height: 1.25; }
.prose h4 { margin: 1.6em 0 0.4em; font-size: 20px; line-height: 1.3; }

.prose strong { font-weight: 600; color: var(--heading); }
.prose small { display: inline-block; font-size: 14px; line-height: 1.6; color: var(--muted); }

.prose blockquote {
  margin: 1.8em 0;
  padding: 0 0 0 1.2em;
  border-left: 2px solid var(--rule-strong);
  font-family: var(--serif);
  font-size: 1.2em;
  line-height: 1.55;
  color: var(--heading);
}

.prose img { margin: 2.2em auto; }
.prose figure { margin: 2.2em 0; }
.prose figure img { margin: 0 auto; }
.prose figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }

.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.6em 0; }

.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--tint);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}
.prose pre { background: var(--tint); padding: 16px 18px; border-radius: 4px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }

.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.prose th { color: var(--heading); font-weight: 600; }

/* Footnotes (kramdown) */
.prose sup { line-height: 0; }
.prose a.footnote { text-decoration: none; font-size: 0.78em; padding: 0 0.1em; }
.prose .footnotes {
  margin-top: 3.2em;
  padding-top: 1.4em;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}
.prose .footnotes ol { padding-left: 1.2em; margin: 0; }
.prose .footnotes p { margin: 0 0 0.6em; }
.prose a.reversefootnote { text-decoration: none; margin-left: 0.2em; }

/* ---------- Homepage ---------- */

.home {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  column-gap: 80px;
  align-items: start;
}

.profile__photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--frame);
}

.profile__name {
  margin: 24px 0 10px;
  font-size: 40px;
  line-height: 1.04;
  letter-spacing: -0.01em;
}

.profile__bio {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
  color: var(--text);
}

.home__body { padding-top: 4px; }
.home__body .prose { font-size: 16.5px; line-height: 1.75; }

/* ---------- Research page ---------- */

.page-research { max-width: none; }

.page-research h3 {
  margin: 0;
  padding-top: 1.4em;
  margin-top: 1.4em;
  border-top: 1px solid var(--rule);
  font-size: 24px;
}
.page-research h2 + h3 { margin-top: 0; padding-top: 0.2em; border-top: 0; }
.page-research h3 a { color: inherit; text-decoration: none; }
.page-research h3 a:hover { color: var(--accent); }
.page-research h3 + p {
  margin: 0.55em 0 0.5em;
  font-size: 14px;
  color: var(--muted);
}

/* Collapsible abstracts: small triangle, then an indented block with a rule down the left */
.prose details { margin: 0.3em 0 0.4em; font-size: 14px; }
.prose summary {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  color: var(--accent);
  user-select: none;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::before {
  content: "";
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.15s ease;
}
.prose details[open] summary::before { transform: rotate(90deg); }
.prose summary:hover { color: var(--accent-hover); }
.prose details > :not(summary) {
  max-width: 800px;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--frame);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
}
.prose details > summary + * { margin-top: 12px; }
.prose details > * + *:not(summary) { padding-top: 0.8em; }
.prose details > summary + * { padding-top: 0; }

/* ---------- Writing index ---------- */

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule-strong);
}
.entry { border-bottom: 1px solid var(--rule); }
.entry__link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 36px;
  align-items: center;
  padding: 30px 0;
  color: inherit;
  text-decoration: none;
}
.entry__date { font-size: 13px; color: var(--muted); letter-spacing: 0.01em; }
.entry__title {
  margin: 6px 0 8px;
  font-size: 27px;
  line-height: 1.22;
  transition: color 0.15s ease;
}
.entry__link:hover .entry__title { color: var(--accent); }
.entry__dek { margin: 0; font-size: 15px; line-height: 1.65; color: var(--text); }
.entry__thumb { width: 280px; }
.entry__thumb img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

/* ---------- Essay ---------- */

.essay__header { margin-bottom: 48px; }

.eyebrow {
  margin: 0 0 20px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow a { color: var(--muted); text-decoration: none; }
.eyebrow a:hover { color: var(--accent); }
.eyebrow .sep { margin: 0 0.6em; }

.essay__title {
  margin: 0 0 18px;
  font-size: 46px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.essay__dek {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  line-height: 1.45;
  color: #5D6461;
}
.essay__dek p { margin: 0; }

.prose--essay { max-width: none; font-size: 17px; line-height: 1.78; }
.prose--essay > p:first-child small { font-style: italic; }
.prose--essay img { width: 100%; }

/* Tufte-style layout: on wide screens the text sits in a reading column and
   footnotes move into the right margin beside the line that cites them.
   On narrower screens everything stays in one column with notes at the end. */
.sidenote { display: none; }

@media (min-width: 900px) {
  .prose--essay { display: flow-root; }      /* keeps a long final note above the footer */
  .prose--essay > * { max-width: calc(100% - 290px); }
  .prose--essay.has-sidenotes .footnotes { display: none; }
  .prose--essay.has-sidenotes a.footnote { pointer-events: none; }

  .sidenote {
    display: block;
    position: relative;
    float: right;
    clear: right;
    width: 240px;
    margin: 0.3em -290px 1em 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.55;
    color: var(--muted);
  }
  .sidenote a { color: var(--accent); }
  .sidenote__num {
    margin-right: 0.35em;
    font-size: 0.8em;
    vertical-align: super;
    line-height: 0;
    color: var(--accent);
  }
}

.essay__footer {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
}
.essay__footer a { text-decoration: none; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .site-main { padding: 40px 0 64px; }
  .site-header__inner { padding: 22px 0 14px; column-gap: 16px; }
  .site-nav { gap: 15px; }
  .site-nav a { font-size: 13.5px; }

  .home { grid-template-columns: 1fr; }
  .profile {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    column-gap: 22px;
    align-items: center;
    margin-bottom: 44px;
  }
  .profile__photo { padding: 4px; }
  .profile__name { margin: 0 0 8px; font-size: 34px; }

  .page-title { font-size: 40px; }
  .page-header { margin-bottom: 32px; }

  .entry__link { grid-template-columns: 1fr; gap: 0; padding: 24px 0; }
  .entry__thumb { display: none; }
  .entry__title { font-size: 24px; }

  .essay__title { font-size: 36px; }
  .essay__dek { font-size: 20px; }
  .prose--essay { font-size: 16.5px; }
}
