/* ---------------------------------------------------------------------
   Sushant Daga — personal site
   Typeset like a preprint about its author: a masthead, an Abstract for
   the bio, the portrait as a numbered figure, and paper-style sections.
   --------------------------------------------------------------------- */

:root {
  --paper: #F4F6F5;
  --paper-raised: #FFFFFF;
  --ink: #1B2130;
  --slate: #5B6472;
  --rule: #D7DBD8;
  --accent: #A6321E;
  --accent-ink: #7C2416;
  --highlight: #FCE49A;

  --serif: "STIX Two Text", "Georgia", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --measure: 42rem;
  --measure-wide: 54rem;
  --measure-breakout: 60rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14171C;
    --paper-raised: #1B1F26;
    --ink: #E7E9E4;
    --slate: #97A0A6;
    --rule: #323942;
    --accent: #E2795F;
    --accent-ink: #F2A98F;
    --highlight: #4A3A14;
  }

  /* Figures exported from the steering pipeline are plain white-background
     matplotlib charts. A stark white rectangle on a near-black page is jarring,
     so dim and mat them instead of leaving them at full brightness. */
  .post-body img {
    background: #ECECEC;
    padding: 1rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
    filter: brightness(0.82) contrast(0.96);
  }
}

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

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

body { overflow-wrap: break-word; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--accent-ink);
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms ease;
}
a:hover { text-decoration-color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0.75em 1em;
  z-index: 100;
  border: 1px solid var(--rule);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- masthead */

.masthead {
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.masthead-inner {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.masthead-name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}

.masthead-nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.masthead-nav a {
  color: var(--slate);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.masthead-nav a:hover { color: var(--accent-ink); }

/* ---------------------------------------------------------------- paper */

.paper {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.paper-narrow { max-width: var(--measure); }

/* ---------------------------------------------------------------- hero */

.hero-kicker {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--slate);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
}

.hero-role {
  font-family: var(--serif);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
  margin: 0 0 2.25rem;
  color: var(--ink);
  max-width: 34ch;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

.portrait {
  margin: 0;
}
.portrait img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}
.portrait figcaption {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--slate);
  margin-top: 0.6rem;
  line-height: 1.5;
}
.fig-label {
  font-family: var(--mono);
  color: var(--accent-ink);
}

.abstract-label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 0.6rem;
}

.abstract-body {
  text-align: justify;
  hyphens: auto;
}
.abstract-body p:first-child { margin-top: 0; }

mark {
  background: none;
  color: var(--ink);
  box-shadow: inset 0 -0.42em 0 var(--highlight);
}
.abstract-body strong {
  font-weight: 600;
  font-style: normal;
  color: var(--ink);
}

.hero-links {
  font-family: var(--sans);
  font-size: 0.92rem;
  margin: 1.75rem 0 0;
}
.hero-links a { text-decoration: none; }

/* ---------------------------------------------------------------- sections */

.section-head {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 1.5rem;
}

.empty-note {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--slate);
  font-style: italic;
}

/* ---------------------------------------------------------------- work list */

.work-list {
  list-style: none;
  margin: 0;
  padding: 2rem 0 0;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.work-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
}


.work-what h3 {
  font-family: var(--serif);
  font-size: 1.08rem;
  margin: 0 0 0.15rem;
}
.work-what h3 a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.work-what h3 a:hover { border-color: var(--accent-ink); color: var(--accent-ink); }

.work-org {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--slate);
  margin: 0 0 0.5rem;
}

.work-summary { margin: 0 0 0.6rem; }

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-list li {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--slate);
  border: 1px solid var(--rule);
  padding: 0.15em 0.55em;
  border-radius: 2px;
}
.tag-list li a {
  display: block;
  margin: -0.15em -0.55em;
  padding: 0.15em 0.55em;
  color: inherit;
  text-decoration: none;
}
.tag-list li:has(a):hover { color: var(--accent-ink); border-color: var(--accent-ink); }

/* ---------------------------------------------------------------- writing list */

.writing-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.writing-list li {
  border-bottom: 1px dotted var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  align-items: baseline;
  padding: 0.75rem 0;
}
.writing-list li:first-child { border-top: 1px dotted var(--rule); }
.writing-list li[hidden] { display: none; }

.writing-link { grid-column: 1; min-width: 0; text-decoration: none; color: var(--ink); }
.writing-link:hover .writing-title { color: var(--accent-ink); }


.writing-title {
  font-family: var(--serif);
  font-size: 1.02rem;
}

.writing-tags {
  grid-column: 2;
  justify-self: end;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.7rem;
}
.writing-tags a { color: var(--slate); text-decoration: none; }
.writing-tags a:hover { color: var(--accent-ink); text-decoration: underline; }

.see-all { font-family: var(--sans); font-size: 0.88rem; }


/* ---------------------------------------------------------------- writing layout */

.writing-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 3rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  align-items: start;
}

.writing-article { max-width: none; margin: 0; padding: 0; }

.tag-filter {
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.tag-filter ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
}
.tag-chip {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--slate);
  background: none;
  border: none;
  padding: 0.2rem 0;
  cursor: pointer;
  line-height: 1.4;
  text-align: left;
}
.tag-chip:hover { color: var(--ink); }
.tag-chip.is-active { color: var(--accent-ink); }

/* ---------------------------------------------------------------- post layout */

.post-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 3rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  align-items: start;
}

.post-article {
  max-width: none;
  margin: 0;
  padding: 0;
}

.post-toc {
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.post-toc-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 0.75rem;
}
.post-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--rule);
}
.post-toc li { margin: 0; }
.post-toc a {
  display: block;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--slate);
  text-decoration: none;
  padding: 0.35rem 0 0.35rem 0.9rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
}
.post-toc a:hover { color: var(--ink); }
.post-toc a.is-active {
  color: var(--accent-ink);
  border-left-color: var(--accent);
}
.post-toc li.toc-h3 a { padding-left: 1.6rem; font-size: 0.8rem; }

/* Only render as a nav when JS has populated it; empty/short docs hide it entirely. */
.post-toc:not([data-ready]) { visibility: hidden; }
.post-toc[data-empty] { display: none; }

/* ---------------------------------------------------------------- post / page */

.back-link { font-family: var(--mono); font-size: 0.8rem; max-width: var(--measure); }
.back-link a { text-decoration: none; }

.post-head { margin: 1rem 0 2.5rem; max-width: var(--measure); }
.post-date {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--slate);
  margin: 0 0 0.4rem;
}
.post-head h1, .page-title {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem);
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

/* Prose stays at a comfortable reading measure; tables and standalone figures
   break out wider so they're not squeezed into the text column (Distill.pub's
   grid pattern, simplified to two tiers). */
.post-body {
  display: grid;
  grid-template-columns: 1fr min(var(--measure), 100%) 1fr;
}
.post-body > * { grid-column: 2; }
.post-body > table,
.post-body > p:has(> img:only-child),
.post-body > p:has(> img:only-child) + p:has(> em:only-child),
.post-body > .table-scroll,
.post-body > div.highlighter-rouge,
.post-body > pre {
  grid-column: 1 / 4;
  width: 100%;
  max-width: var(--measure-breakout);
  justify-self: center;
}

.post-body h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin-top: 3.25rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 4.5rem;
}
.post-body h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.post-body h3 { font-family: var(--serif); font-size: 1.1rem; scroll-margin-top: 4.5rem; }
.post-body .heading-anchor {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--slate);
  text-decoration: none;
  margin-left: 0.5em;
  opacity: 0;
  transition: opacity 120ms ease;
}
.post-body h2:hover .heading-anchor,
.post-body h3:hover .heading-anchor,
.post-body .heading-anchor:focus-visible { opacity: 1; }

.post-body > p:first-of-type { font-size: 1.12em; }

.post-body p { margin: 1.1em 0; }
.post-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
.post-body pre {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85em;
  line-height: 1.55;
}
.post-body pre code { border: none; padding: 0; background: none; }

/* Rouge syntax highlighting — minimal, tuned to the site palette rather than a stock theme. */
.post-body .highlight .c, .post-body .highlight .c1, .post-body .highlight .cm { color: var(--slate); font-style: italic; }
.post-body .highlight .k, .post-body .highlight .kn, .post-body .highlight .kd, .post-body .highlight .kc { color: var(--accent-ink); }
.post-body .highlight .s, .post-body .highlight .s1, .post-body .highlight .s2, .post-body .highlight .sa { color: #4B7A3E; }
.post-body .highlight .n, .post-body .highlight .nb { color: var(--ink); }
.post-body .highlight .nf, .post-body .highlight .nc { color: #2B5B8C; }
.post-body .highlight .mi, .post-body .highlight .mf { color: #8C5B2B; }
.post-body .highlight .o, .post-body .highlight .p { color: var(--slate); }
@media (prefers-color-scheme: dark) {
  .post-body .highlight .s, .post-body .highlight .s1, .post-body .highlight .s2, .post-body .highlight .sa { color: #8FBF7F; }
  .post-body .highlight .nf, .post-body .highlight .nc { color: #7FAAD6; }
  .post-body .highlight .mi, .post-body .highlight .mf { color: #D6A97F; }
}
.post-body blockquote {
  margin: 1.5em 0;
  padding-left: 1.25em;
  border-left: 2px solid var(--accent);
  color: var(--slate);
  font-style: italic;
}

/* Numbered steps (recipes, protocols) sit inside a light boundary box —
   enough to read as a distinct, self-contained unit without the
   background fill / heavier framing a code block gets. */
.post-body ol {
  margin: 1.5em 0;
  padding: 1.1em 1.4em 1.1em 2.4em;
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.post-body ol li {
  margin: 0.7em 0;
}
.post-body ol li::marker {
  color: var(--accent-ink);
  font-weight: 600;
}
.post-body hr {
  width: 100%;
  height: 0;
  margin: 2.5em 0;
  border: none;
  border-top: 1px solid var(--rule);
}

.post-body figcaption,
.post-body > p:has(> img:only-child) + p:has(> em:only-child) {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--slate);
  text-align: center;
}

/* Tables: readable at a glance, scrollable rather than crushed on mobile. */
.table-scroll { overflow-x: auto; }
.post-body table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.5;
}
.post-body th,
.post-body td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.post-body th {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--slate);
  border-bottom: 2px solid var(--ink);
}
.post-body tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}

.page-title { margin-top: 1rem; }

/* ------------------------------------------------------------------ related */

.related-block {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}
.related-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 0.6rem;
}
.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.related-list a {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
}

/* ---------------------------------------------------------------- citation */

.cite-block {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}
.cite-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 0.6rem;
}
.cite-line {
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--slate);
  margin: 0 0 0.75rem;
}
.cite-bibtex {
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.55;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  color: var(--slate);
  margin: 0;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  border-top: 1px solid var(--rule);
}

.footer-eyebrow {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent-ink);
  margin: 0 0 1rem;
}

.footer-links {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}
.footer-links a { text-decoration: none; color: var(--ink); }
.footer-links a:hover { color: var(--accent-ink); }

.footer-fine {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--slate);
  margin: 0;
}

/* ---------------------------------------------------------------- reveal-on-scroll */

[data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 500ms ease, transform 500ms ease;
}
[data-reveal].is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 960px) {
  .writing-layout { grid-template-columns: minmax(0, 1fr); padding: 2rem 1.25rem 3rem; gap: 0; }
  .tag-filter {
    position: static;
    max-height: none;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
  }
  .tag-filter ul { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
  .tag-chip { border: 1px solid var(--rule); border-radius: 2px; padding: 0.25rem 0.6rem; }
  .tag-chip.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

  .post-layout { grid-template-columns: minmax(0, 1fr); padding: 2rem 1.25rem 3rem; gap: 0; }
  .post-toc {
    position: static;
    max-height: none;
    order: -1;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
  }
  .post-toc ol { columns: 2; column-gap: 1.5rem; border-left: none; }
  .post-toc li.toc-h3 { display: none; }
  .post-toc a { padding: 0.3rem 0; border-left: none; break-inside: avoid; }
  .post-toc a.is-active { color: var(--accent-ink); }
}

@media (max-width: 640px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .portrait { max-width: 12rem; }
  .masthead-inner { padding: 1rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .masthead-nav { gap: 1rem; }
  .paper { padding: 2rem 1.25rem 3rem; }
  .post-toc ol { columns: 1; }
  .writing-list li { grid-template-columns: minmax(0, 1fr); row-gap: 0.25rem; }
  .writing-tags { grid-column: 1 / -1; justify-self: start; text-align: left; }
}
