/* ---------------------------------------------------------------
   abhaymittal.com — stylesheet
   One file. Mobile-first. No frameworks.
   --------------------------------------------------------------- */

/* Tokens ------------------------------------------------------- */
:root {
  --bg:        #FAF8F3;
  --bg-sunk:  #F4F0E5;
  --ink:       #1A1A1A;
  --ink-soft:  #2A2823;
  --muted:     #6F665A;
  --muted-2:   #8C8475;
  --rule:      #E6E0D2;
  --rule-soft: #EFEADC;
  --accent:    #B85C2E;     /* burnt terracotta */
  --accent-ink:#8E441E;
  --code-bg:   #F1ECDD;

  --serif: "Source Serif 4", "Source Serif Pro", Iowan Old Style,
           "Apple Garamond", Garamond, "Times New Roman", serif;
  --sans:  "IBM Plex Sans", -apple-system, BlinkMacSystemFont,
           "Segoe UI", Roboto, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo,
           Consolas, monospace;

  --measure: 65ch;
  --measure-narrow: 56ch;
  --gutter: clamp(1.25rem, 5vw, 2rem);
}

/* Reset-ish ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Base ---------------------------------------------------------- */
html {
  font-size: 17px;          /* slightly larger base; rem values scale uniformly */
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.7;
  font-feature-settings: "kern", "liga", "onum";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* Layout ------------------------------------------------------- */
.wrap {
  /* Single centered column. Wider on big screens to feel less
     cramped, capped so prose stays readable. */
  max-width: clamp(40rem, 82vw, 60rem);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 4rem;
}

main { display: block; }

/* Site header / nav ------------------------------------------- */
.site-head {
  font-family: var(--sans);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  margin-bottom: 3rem;
  color: var(--muted);
}
.site-head a { color: inherit; text-decoration: none; }
.site-head .brand {
  color: var(--ink);
  font-weight: 500;
}
.site-head nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}
.site-head nav a {
  position: relative;
  padding: 2px 0;
}
.site-head nav a:hover,
.site-head nav a[aria-current="page"] {
  color: var(--ink);
}
.site-head nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: var(--ink);
}

/* Typography --------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 6vw, 2.75rem); font-weight: 400; letter-spacing: -0.015em; }
h2 { font-size: 1.375rem; margin-top: 2.5rem; }
h3 { font-size: 1.125rem; margin-top: 2rem; }

p { margin: 0 0 1.1em; text-wrap: pretty; }
p + p { text-indent: 0; }

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

::selection { background: rgba(184, 92, 46, 0.18); }

/* Hero / bio --------------------------------------------------- */
/* Top: headshot left + name/tagline right, together spanning the
   full column. Below: links row, then bio prose at full width. */
.hero { margin-bottom: 2.75rem; }
.hero-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.6rem;
}
.hero .name { margin: 0 0 0.4rem; }
.hero .tagline {
  font-family: var(--serif);
  font-size: 1.0625rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0;
  text-wrap: pretty;
}
.headshot {
  width: 132px; height: 132px;
  border-radius: 10px;
  object-fit: cover;
  object-position: center 22%;
  filter: grayscale(0.5) sepia(0.18) contrast(0.96) brightness(0.99);
  background: var(--bg-sunk);
}
.bio p { margin-bottom: 1em; }
.bio p:last-child { margin-bottom: 0; }
@media (min-width: 560px) {
  .hero-top {
    grid-template-columns: 148px 1fr;
    gap: 1.6rem;
  }
  .headshot { width: 148px; height: 148px; }
}

/* Inline link row (email / scholar / etc.) -------------------- */
.linkrow {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 2rem;          /* sits above the bio */
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.05rem;
  list-style: none;
  padding: 0;
}
.linkrow a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
}
.linkrow a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.linkrow a { display: inline-flex; align-items: baseline; gap: 0.4em; }
.linkrow-ico {
  width: 0.95em;
  height: 0.95em;
  flex: 0 0 auto;
  color: var(--muted);
  transform: translateY(0.13em);   /* nudge to optical baseline */
  transition: color 0.15s ease;
  display: none;                    /* hidden by default; .with-icons reveals */
}
.linkrow.with-icons .linkrow-ico { display: inline-block; }
.linkrow a:hover .linkrow-ico { color: var(--accent); }

/* Section header (reusable) ---------------------------------- */
/* Small uppercase label with a thin rule beneath. Pair with any
   <section> heading: <h2 class="section-header">Building</h2>.
   `.section-head` is kept as an alias for legacy markup. */
.section { margin: 3.25rem 0; }
.section-header,
.section-head {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

/* Entry list (reusable row pattern) -------------------------- */
/* A flat list of rows. Use `.entries` on the container (any
   <ol>/<ul>/<div>) and `.entry` on each row (any element).
   Add `.with-thumb` for the thumbnail-left + content-right layout
   used by Selected Work. Sub-elements: `.entry-title`,
   `.entry-meta`, `.entry-desc`, `.entry-thumb`. */
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entries > li,
.entries > .entry {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.entries > li:last-child,
.entries > .entry:last-child { border-bottom: 0; }

.entry-title {
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 500;
  margin: 0 0 0.15rem;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.entry-title a { color: inherit; }
.entry-title a:hover { color: var(--accent-ink); }

.entry-meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  margin: 0 0 0.15rem;
}
.entry-meta .dot { color: var(--muted-2); margin: 0 0.4em; }

.entry-desc {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}

/* Thumbnail-row variant (Selected Work, Recent Writing, etc.) */
/* Treatment: 4:3 frame, thin border slightly darker than page bg,
   muted saturation on the image, subtle warm accent overlay so
   real paper figures feel native to the palette. */
.entries.with-thumb > li,
.entries.with-thumb > .entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  padding: 1.1rem 0;
}
.entry-thumb {
  position: relative;
  display: block;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 2 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-sunk);
  border: 1px solid #D9D2BE;       /* tone slightly darker than --bg */
  isolation: isolate;
}
.entry-thumb img,
.entry-thumb svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Mute oversaturated paper figures and align brightness with page */
  filter: saturate(0.82) brightness(0.985) contrast(0.97);
}
.entry-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(184, 92, 46, 0.07);  /* warm accent overlay */
  pointer-events: none;
}
@media (min-width: 560px) {
  .entries.with-thumb > li,
  .entries.with-thumb > .entry {
    grid-template-columns: 220px 1fr;
    gap: 1.25rem;
    align-items: start;
  }
  .entry-thumb { max-width: 220px; }
}
.entries.notes > li { padding: 0.65rem 0; }
.entries.notes .entry-title {
  font-size: 1rem;
  font-weight: 500;
}
.entries.notes .entry-desc { font-size: 0.92rem; }

/* Inline note (no own page) ---------------------------------- */
.note-inline { padding: 1rem 0; border-bottom: 1px solid var(--rule-soft); }
.note-inline:last-child { border-bottom: 0; }
.note-inline .note-date {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  margin: 0 0 0.35rem;
}
.note-inline p {
  font-family: var(--serif);
  font-size: 0.98rem;
  margin: 0 0 0.6rem;
  line-height: 1.65;
}
.note-inline p:last-child { margin-bottom: 0; }

/* "More" link ------------------------------------------------- */
.more-link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  margin-top: 1.25rem;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.more-link:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* Tags -------------------------------------------------------- */
.tags {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.tags span + span::before { content: " · "; color: var(--muted-2); }

/* Article (essay / note) -------------------------------------- */
article.post header {
  margin-bottom: 2.25rem;
}
article.post .post-title {
  font-size: clamp(1.75rem, 5vw, 2.3rem);
  font-weight: 400;
  margin: 0 0 0.6rem;
  letter-spacing: -0.015em;
}
article.note-page .post-title {
  font-size: clamp(1.4rem, 4.4vw, 1.75rem);
  font-style: italic;
}
article.post .post-meta {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  align-items: baseline;
}
article.post .post-meta .dot { color: var(--muted-2); }
article.post .crosspost {
  font-family: var(--sans);
  font-size: 0.82rem;
  margin-top: 1rem;
  color: var(--muted);
}
article.post .crosspost a { color: var(--accent-ink); }

/* Long-form prose --------------------------------------------- */
.prose {
  max-width: none;
  font-size: 1.0625rem;
  line-height: 1.7;
}
.prose h2 { margin-top: 2.4rem; font-size: 1.375rem; }
.prose h3 { margin-top: 1.9rem; font-size: 1.125rem; }
.prose p { margin: 0 0 1.15em; }
.prose blockquote {
  margin: 1.6em 0;
  padding: 0.1em 0 0.1em 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.15em; }
.prose li { margin: 0.25em 0; }
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.08em 0.35em;
  border-radius: 3px;
}
.prose pre {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
  background: var(--code-bg);
  padding: 1rem 1.1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5em 0;
}
.prose pre code { background: transparent; padding: 0; font-size: inherit; }
.prose figure { margin: 1.6em 0; }
.prose figcaption {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.5rem;
  text-align: center;
}

/* Footnotes --------------------------------------------------- */
.prose a.fn-ref {
  color: var(--accent-ink);
  font-size: 0.78em;
  vertical-align: super;
  line-height: 0;
  border-bottom: 0;
  padding: 0 0.1em;
}
.prose a.fn-ref::before { content: "["; }
.prose a.fn-ref::after  { content: "]"; }
.footnotes {
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.footnotes ol { padding-left: 1.4em; }
.footnotes li { margin: 0.4em 0; }
.footnotes a.fn-back {
  text-decoration: none;
  color: var(--accent-ink);
  margin-left: 0.3em;
}

/* Post footer ------------------------------------------------- */
.post-foot {
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
}
.post-foot a { color: var(--ink-soft); border-bottom: 1px solid var(--rule); }
.post-foot a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* Reading page groups ---------------------------------------- */
.year-group { margin: 2.5rem 0; }
.year-group h2 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.6rem;
  margin-top: 0;
}
.reading-list { list-style: none; padding: 0; margin: 0; }
.reading-list li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.reading-list li:last-child { border-bottom: 0; }
.reading-list .title {
  font-family: var(--serif);
  font-size: 1.025rem;
  color: var(--ink);
  font-style: italic;
}
.reading-list .author {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: 0.25rem;
}
.reading-list .reaction {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0.25rem 0 0;
  line-height: 1.55;
}
.kind {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  text-transform: uppercase;
  margin-right: 0.5rem;
  vertical-align: 0.05em;
}

/* Site footer ------------------------------------------------- */
.site-foot {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  letter-spacing: 0.01em;
}
.site-foot a { color: inherit; border-bottom: 1px solid var(--rule); }
.site-foot a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* Page intros (for index pages other than home) -------------- */
.page-intro {
  margin: 0 0 2.5rem;
}
.page-intro h1 {
  font-size: clamp(1.6rem, 4.6vw, 2rem);
  font-weight: 400;
  margin: 0 0 0.6rem;
  letter-spacing: -0.015em;
}
.page-intro p {
  color: var(--ink-soft);
  font-size: 1rem;
  margin: 0;
}

@media (min-width: 720px) {
  .wrap { padding-top: 3.5rem; }
}

/* Print -------------------------------------------------------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-head nav, .site-foot, .post-foot { display: none; }
  a { color: #000; text-decoration: underline; }
  .headshot { filter: grayscale(1); }
}

/* Reduced motion respected */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Progressive-enhancement layer ------------------------------- */
/* Smooth in-page scroll, opt-in via :root.js */
html { scroll-behavior: smooth; }

/* Reading progress bar (essay pages, JS-injected) ------------ */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 50;
  transition: width 80ms linear;
  pointer-events: none;
}

/* Heading anchor / copy-link button -------------------------- */
.prose h2, .prose h3 { position: relative; }
.heading-link {
  display: inline-block;
  margin-left: 0.4em;
  font-family: var(--sans);
  font-size: 0.7em;
  color: var(--muted-2);
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
  vertical-align: 0.15em;
  padding: 0.1em 0.25em;
  border-radius: 3px;
  letter-spacing: 0.02em;
}
.prose h2:hover .heading-link,
.prose h3:hover .heading-link,
.heading-link:focus-visible {
  opacity: 1;
  color: var(--accent-ink);
  outline: none;
}
.heading-link.copied { color: var(--accent-ink); opacity: 1; }
.heading-link.copied::after { content: " copied"; }

/* Footnote popover (essays, JS-injected) -------------------- */
.fn-pop {
  position: absolute;
  z-index: 40;
  max-width: min(22rem, calc(100vw - 2rem));
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 1px 1px rgba(26,26,26,0.04), 0 6px 24px -8px rgba(26,26,26,0.18);
  padding: 0.7rem 0.95rem;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.fn-pop a { color: var(--accent-ink); }
.fn-pop::before {
  content: "";
  position: absolute;
  top: -5px;
  left: var(--arrow-x, 14px);
  width: 8px; height: 8px;
  background: var(--bg);
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  transform: rotate(45deg);
}

/* JS-only show; nothing visible if scripts fail */
.no-js .reading-progress,
.no-js .heading-link,
.no-js .fn-pop { display: none !important; }
