/* ==========================================================================
   Aditya Vijaykumar — site styles
   Palette pulled from the portrait: warm paper, ink, terracotta, teal.
   ========================================================================== */

:root {
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #faf8f5;
  --bg-elev: #ffffff;
  --bg-sunken: #f2eee8;
  --ink: #1a1714;
  --ink-2: #47413c;
  --muted: #776f68;
  --line: #e8e2da;
  --line-strong: #d5ccc1;
  --accent: #b4462b;
  --accent-ink: #933620;
  --accent-soft: #f7e6de;
  --teal: #2b676b;
  --teal-soft: #e0eeec;
  --shadow: 0 1px 2px rgb(26 23 20 / 0.04), 0 12px 32px -16px rgb(26 23 20 / 0.18);

  --radius: 16px;
  --container: 1120px;
  --measure: 68ch;
  --header-h: 64px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121110;
  --bg-elev: #1a1817;
  --bg-sunken: #211f1d;
  --ink: #f3eee8;
  --ink-2: #cbc3ba;
  --muted: #958c83;
  --line: #2b2825;
  --line-strong: #3c3834;
  --accent: #f0896a;
  --accent-ink: #f6a68d;
  --accent-soft: rgb(240 137 106 / 0.14);
  --teal: #86c9c6;
  --teal-soft: rgb(134 201 198 / 0.12);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -20px rgb(0 0 0 / 0.7);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110;
    --bg-elev: #1a1817;
    --bg-sunken: #211f1d;
    --ink: #f3eee8;
    --ink-2: #cbc3ba;
    --muted: #958c83;
    --line: #2b2825;
    --line-strong: #3c3834;
    --accent: #f0896a;
    --accent-ink: #f6a68d;
    --accent-soft: rgb(240 137 106 / 0.14);
    --teal: #86c9c6;
    --teal-soft: rgb(134 201 198 / 0.12);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -20px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

main { flex: 1; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
p { margin: 0; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

::selection { background: var(--accent-soft); color: var(--ink); }

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

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 40px);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

.eyebrow {
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(16px);
  backdrop-filter: saturate(1.5) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.25s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 25%;
  box-shadow: 0 0 0 1px var(--line);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.site-nav { display: flex; align-items: center; gap: 2px; margin-right: 8px; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav-link:hover { color: var(--ink); background: var(--bg-sunken); }
.nav-link[aria-current="page"] { color: var(--ink); background: var(--bg-sunken); }
.nav-link .ext { width: 13px; height: 13px; opacity: 0.55; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--bg-elev); }
.icon-btn svg { width: 18px; height: 18px; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.menu-toggle { display: none; }
.menu-toggle .icon-close { display: none; }
.site-header.is-open .menu-toggle .icon-close { display: block; }
.site-header.is-open .menu-toggle .icon-menu { display: none; }

@media (max-width: 720px) {
  .menu-toggle { display: inline-grid; }
  .site-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 8px clamp(20px, 5vw, 40px) 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .site-header.is-open .site-nav { display: flex; }
  .site-header.is-open { border-bottom-color: var(--line); background: var(--bg); }
  .nav-link { padding: 12px 14px; border-radius: 12px; font-size: 18px; }
}

/* --- Buttons, chips, socials --------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-out);
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; transition: transform 0.25s var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }
.btn:hover .arrow-ext { transform: translate(2px, -2px); }

.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary:hover { color: #1a0d08; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary:hover { color: #1a0d08; }
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding-inline: 12px; }
.btn-ghost:hover { color: var(--ink); border-color: transparent; background: var(--bg-sunken); }

.link-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip-venue { background: var(--teal-soft); border-color: transparent; color: var(--teal); }
.chip-venue:hover { color: var(--teal); border-color: var(--teal); }

.socials { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.socials a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.socials a:hover { color: var(--ink); background: var(--bg-sunken); }
.socials svg { width: 19px; height: 19px; }

/* --- Home: hero ---------------------------------------------------------- */

.hero { padding-block: clamp(40px, 8vw, 104px) clamp(24px, 4vw, 48px); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
}

.hero-title {
  margin: 0 0 28px;
  font-family: var(--font-serif);
  font-size: clamp(48px, 7.4vw, 88px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.hero-title .ital { font-style: italic; letter-spacing: -0.02em; }

.hero-lede {
  max-width: 34em;
  margin-bottom: 32px;
  font-size: clamp(18px, 1.7vw, 20px);
  line-height: 1.6;
  color: var(--ink-2);
}
.hero-lede a,
.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.hero-lede a:hover,
.prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 28px; }
.hero .socials { margin-left: -10px; }

.hero-photo {
  position: relative;
  isolation: isolate;
  justify-self: end;
  width: 100%;
  max-width: 400px;
  margin: 0;
}
.hero-photo::before {
  content: "";
  position: absolute;
  z-index: -1;
  right: -16px;
  bottom: -16px;
  width: 62%;
  height: 62%;
  border-radius: 28px;
  background: var(--teal-soft);
}
.hero-photo img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 20%;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-photo { order: -1; justify-self: start; max-width: 112px; }
  .hero-photo::before { display: none; }
  .hero-photo img { aspect-ratio: 1; border-radius: 24px; }
}

/* --- Home: the hero is the whole page, centred between header and footer */

.is-home main { display: flex; align-items: center; }
.is-home .hero { padding-block: clamp(32px, 6vw, 80px); }
.is-home .site-footer .socials { display: none; }

/* --- Inner pages --------------------------------------------------------- */

.page-head { padding-block: clamp(48px, 8vw, 96px) clamp(28px, 4vw, 48px); }

.page-title {
  max-width: 18em;
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.028em;
  color: var(--ink);
}
.page-lede {
  max-width: 36em;
  margin-top: 22px;
  font-size: clamp(18px, 1.7vw, 21px);
  line-height: 1.55;
  color: var(--ink-2);
}
.post-tags { margin-top: 24px; }

.page-body { padding-bottom: clamp(72px, 10vw, 128px); }

/* --- Prose (markdown content) -------------------------------------------- */

.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose :where(p, ul, ol, figure, blockquote, pre, table) { margin: 0 0 1.15em; }
.prose > p:first-child { font-size: 1.14em; line-height: 1.6; color: var(--ink); }

.prose h2 {
  margin: 2.2em 0 0.7em;
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.prose h3 { margin: 1.8em 0 0.5em; font-size: 18px; font-weight: 600; color: var(--ink); }
.prose strong { font-weight: 600; color: var(--ink); }

.prose code {
  padding: 0.15em 0.45em;
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.prose pre {
  overflow-x: auto;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-sunken);
  font-size: 14px;
  line-height: 1.6;
}
.prose pre code { padding: 0; background: none; }

.prose ul { padding-left: 1.25em; }
.prose ul li::marker { color: var(--accent); }
.prose li + li { margin-top: 0.5em; }
.prose li > p { margin-bottom: 0.6em; }
.prose li > p:last-child { margin-bottom: 0; }
.prose li > ul { margin: 0.6em 0 0; }

/* Numbered lists become editorial rows with mono counters */
.prose ol { padding: 0; list-style: none; counter-reset: row; }
.prose ol > li {
  position: relative;
  margin: 0;
  padding: 20px 0 20px 60px;
  border-top: 1px solid var(--line);
  counter-increment: row;
}
.prose ol > li:last-child { border-bottom: 1px solid var(--line); }
.prose ol > li::before {
  content: counter(row, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 23px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.prose ol > li > ul { margin-top: 12px; }
.prose ol > li > ul > li { font-size: 0.95em; }

.prose img { border-radius: var(--radius); }
.prose figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); }
.prose hr { margin: 3em 0; border: 0; border-top: 1px solid var(--line); }
.prose blockquote {
  padding-left: 1.2em;
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: 1.15em;
  font-style: italic;
  color: var(--ink);
}
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; }
.prose th, .prose td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.prose th { color: var(--ink); font-weight: 600; }

/* Card lists — add `{: .cards}` after a markdown list */
.prose ul.cards { display: grid; gap: 12px; padding: 0; list-style: none; }
.prose ul.cards > li {
  margin: 0;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
.prose ul.cards > li:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.prose ul.cards > li p { margin: 0; }

.post-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 3em; padding-top: 1.5em; border-top: 1px solid var(--line); }

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

.research-intro { max-width: var(--measure); }
.research-intro .prose { margin-bottom: 24px; }
.research-intro .prose p { font-size: 17px; color: var(--ink-2); }

.xkcd { margin: 0 0 clamp(40px, 6vw, 64px); }
.xkcd img {
  width: 100%;
  padding: clamp(12px, 2.5vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
:root[data-theme="dark"] .xkcd img { filter: invert(0.92) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .xkcd img { filter: invert(0.92) hue-rotate(180deg); }
}
.xkcd figcaption { margin-top: 12px; font-size: 13px; color: var(--muted); }
.xkcd figcaption a { color: inherit; text-underline-offset: 3px; }
.xkcd figcaption a:hover { color: var(--accent); }

.paper-toc {
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  display: flex;
  gap: 6px;
  margin: clamp(48px, 7vw, 72px) calc(-1 * clamp(20px, 5vw, 40px)) 0;
  padding: 12px clamp(20px, 5vw, 40px);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line);
}
.paper-toc::-webkit-scrollbar { display: none; }
.paper-toc a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.paper-toc a:hover { color: var(--ink); border-color: var(--line-strong); }
.paper-toc a span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.paper-section { margin-top: clamp(32px, 5vw, 56px); }
.paper-section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}
.paper-section-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.paper-section-head .count { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.paper-section-note { margin-top: 14px; font-size: 15px; color: var(--muted); }

.papers { max-width: 920px; margin: 0; padding: 0; list-style: none; }

.paper {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 24px;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}
.paper-year {
  padding-top: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.paper-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.006em;
  color: var(--ink);
  text-wrap: pretty;
}
.paper-title a {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0 1px;
  transition: color 0.15s ease, background-size 0.35s var(--ease-out);
}
.paper-title a:hover { color: var(--accent); background-size: 100% 1px; }
.paper-authors { margin-bottom: 12px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.paper-authors strong { font-weight: 600; color: var(--ink); }
.paper-authors em { font-style: italic; }
.paper-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.paper-note { margin-left: 4px; font-size: 13px; font-style: italic; color: var(--muted); }

@media (max-width: 640px) {
  .paper { grid-template-columns: 1fr; gap: 4px; padding: 22px 0; }
  .paper-year:empty { display: none; }
  .paper-year { padding-top: 0; }
  .paper-title { font-size: 19px; }
}

/* --- 404 ----------------------------------------------------------------- */

.lost { padding-block: clamp(72px, 14vw, 160px); }
.lost .page-lede { margin-bottom: 32px; }

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

.site-footer { border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 32px;
  padding-block: 24px 32px;
}
.footer-inner .sep { margin-inline: 4px; color: var(--line-strong); }
.footer-inner .socials { margin-right: -10px; }
@media (max-width: 640px) {
  .footer-inner { flex-direction: column-reverse; align-items: flex-start; }
  .footer-inner .socials { margin: 0 0 0 -10px; }
}

/* --- Motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise 0.7s var(--ease-out) var(--delay, 0ms) backwards; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
