/* chaitanyaarora.com: one stylesheet for the homepage and the case studies. */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #5f5b53;
  --line: #e4e0d6;
  --accent: #0f5c4a;
  --accent-soft: #e4eee9;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --measure: 44rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1a1a18;
    --text: #ecebe6;
    --muted: #a6a297;
    --line: #2e2d29;
    --accent: #72c9a8;
    --accent-soft: #1a2b25;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem .75rem; z-index: 10; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: .5rem 1.5rem; padding-top: 1rem; padding-bottom: 1rem;
}
.site-name { font-weight: 600; color: var(--text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--text); }

/* Type */
h1, h2, h3 { line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 6vw, 3.1rem); margin: 0 0 1rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; margin: 0 0 1rem; }
h3 { font-size: 1.15rem; margin: 0; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; margin: 0 0 1rem; }
li { margin-bottom: .45rem; }
li::marker { color: var(--muted); }
strong { font-weight: 600; }

.eyebrow {
  font-family: var(--mono); font-size: .78rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .6rem;
}
.lede { font-size: 1.22rem; line-height: 1.55; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Sections */
section { padding: 3.25rem 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
.section-intro { color: var(--muted); margin-bottom: 1.75rem; }

/* Hero */
.hero { padding: 4.5rem 0 3.25rem; }
.hero .lede { max-width: 40rem; }
.hero-meta { font-family: var(--mono); font-size: .9rem; color: var(--muted); margin: 1.25rem 0 1.75rem; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px; font-size: .95rem; font-weight: 500;
  text-decoration: none; border: 1px solid var(--line); color: var(--text); background: var(--surface);
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-primary:hover { opacity: .92; }

/* Selected work cards */
.cards { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .cards .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.card {
  display: flex; flex-direction: column; gap: .35rem;
  padding: 1.15rem 1.2rem 1.1rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); text-decoration: none;
  transition: border-color .15s ease;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card .stat { font-family: var(--mono); font-size: 1.45rem; font-weight: 500; color: var(--accent); letter-spacing: -0.02em; }
.card .stat-label { font-size: .88rem; color: var(--muted); margin-bottom: .5rem; }
.card h3 { font-size: 1.05rem; }
.card p { font-size: .95rem; color: var(--muted); margin: 0; }
.card .more { margin-top: auto; padding-top: .6rem; font-size: .9rem; color: var(--accent); }

/* Experience */
.role { padding: 1.75rem 0; border-top: 1px solid var(--line); }
.role:first-of-type { border-top: 0; padding-top: .25rem; }
.role-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .15rem 1rem; }
.role-dates { font-family: var(--mono); font-size: .85rem; color: var(--muted); white-space: nowrap; }
.role-title { color: var(--muted); margin: .2rem 0 .85rem; }
.role-context { margin-bottom: .85rem; }
.role ul { margin-bottom: .85rem; }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 0; padding: 0; list-style: none; }
.tags li {
  margin: 0; font-family: var(--mono); font-size: .76rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .55rem;
}

.case-link { font-weight: 500; white-space: nowrap; }

/* Posts */
.posts { list-style: none; padding: 0; margin: 0 0 1rem; }
.posts li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.posts time { font-family: var(--mono); font-size: .85rem; color: var(--muted); }

/* Education list */
.plain { list-style: none; padding: 0; }
.plain li { margin-bottom: .75rem; }

/* Contact */
.contact-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.contact-list li { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: .45rem 0; margin: 0; }
.contact-list span { font-family: var(--mono); font-size: .85rem; color: var(--muted); padding-top: .1rem; }
.contact-list a { overflow-wrap: anywhere; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 1.75rem 0 2.5rem; font-size: .88rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; }
.site-footer a { color: var(--muted); }

/* Case-study pages */
.article-head { padding-top: 3.25rem; padding-bottom: 2rem; }
.article-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
.back { display: inline-block; margin-bottom: 1.75rem; font-size: .92rem; text-decoration: none; }
.facts {
  display: grid; grid-template-columns: 1fr; gap: .9rem 1.5rem; margin: 0 0 1rem;
  padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
@media (min-width: 600px) { .facts { grid-template-columns: 1fr 1fr; } }
.facts div { min-width: 0; }
.facts dt { font-family: var(--mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.facts dd { margin: .15rem 0 0; font-size: .97rem; }
.facts .wide { grid-column: 1 / -1; }

.article section { padding: 2.25rem 0; }
.article h2 { font-size: 1.35rem; }
.article h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
.callout {
  margin: 1.25rem 0; padding: 1rem 1.2rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0;
}
.callout p:last-child { margin-bottom: 0; }
.callout code { background: var(--surface); }
code { font-family: var(--mono); font-size: .9em; background: var(--accent-soft); padding: .05em .35em; border-radius: 4px; }

.next { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding: 2rem 0 0; }

@media print {
  .site-header, .skip, .actions, .contents-rail, .contents-inline, .post-nav { display: none; }
  body { background: #fff; color: #000; }
  section { border: 0; padding: 1.25rem 0; }
}

/* Blog */
.site-nav a[aria-current="page"] { color: var(--text); }

.byline { margin: 0; font-size: .95rem; color: var(--muted); }
.byline a { color: var(--muted); }

.post-head { padding-top: 3rem; padding-bottom: 1.25rem; }
.post-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--text); text-decoration: underline; }

/* Blog index: grouped by year */
.post-index { padding-bottom: 3rem; }
.year-group h2 {
  margin: 2rem 0 .25rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: .85rem; font-weight: 500; letter-spacing: .06em; color: var(--muted);
}
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { margin: 0; padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.post-list h3 { font-size: 1.3rem; margin: 0 0 .25rem; }
.post-list h3 a { color: var(--text); text-decoration: none; }
.post-list h3 a:hover { color: var(--accent); text-decoration: underline; }
.post-list p { margin: .5rem 0 0; }
.post-list .post-meta { margin: 0; font-family: var(--mono); font-size: .85rem; color: var(--muted); }

/* Contents: a collapsed list under the byline, and a sticky rail in the margin on wide screens */
.contents-inline {
  margin: 1.5rem 0 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: .92rem;
}
.contents-inline summary {
  padding: .7rem 1rem; cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: .8rem; color: var(--muted);
}
.contents-inline summary::-webkit-details-marker { display: none; }
.contents-inline summary::after { content: " \25BE"; }
.contents-inline[open] summary::after { content: " \25B4"; }
.contents-inline ol { list-style: none; margin: 0; padding: 0 .5rem .6rem; }
.contents-inline a { display: block; padding: .4rem .5rem; border-radius: 6px; color: var(--text); text-decoration: none; line-height: 1.35; }
.contents-inline a:hover { background: var(--accent-soft); }
.contents-inline a[aria-current="location"] { background: var(--accent-soft); }

.contents-rail { display: none; }
@media (min-width: 1280px) {
  .contents-inline { display: none; }
  .post-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr); }
  .post-grid > .post-body { grid-column: 2; grid-row: 1; }
  .contents-rail { display: block; grid-column: 3; grid-row: 1; padding-left: 1.5rem; }
  .contents-rail nav {
    position: sticky; top: 1.5rem; max-width: 15rem; max-height: calc(100vh - 3rem);
    overflow-y: auto; padding: .25rem;
  }
  .contents-title {
    margin: 0 0 .5rem; font-family: var(--mono); font-size: .75rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  }
  .contents-rail ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
  .contents-rail a {
    display: block; margin-left: -1px; padding: .3rem .8rem; border-left: 2px solid transparent;
    color: var(--muted); font-size: .85rem; line-height: 1.35; text-decoration: none;
  }
  .contents-rail a:hover { color: var(--text); }
  .contents-rail a[aria-current="location"] { color: var(--text); border-left-color: var(--accent); }
}

/* End of a post: older, all posts, newer */
.post-nav { margin-top: 1rem; }
.post-nav-row {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 1rem 1.5rem; padding: 1.5rem 0 3rem; border-top: 1px solid var(--line);
}
.post-nav a { display: flex; flex-direction: column; gap: .15rem; max-width: 16rem; color: var(--text); text-decoration: none; }
.post-nav a:hover { color: var(--accent); }
.post-nav a span { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.post-nav-newer { margin-left: auto; text-align: right; }

/* Footer on blog pages: contact lives here, so "Contact" in the header stays on the page */
.site-footer-blog { margin-top: 1rem; }
.site-footer-blog .wrap { display: block; }
.footer-lead {
  margin: 0 0 .6rem; font-family: var(--mono); font-size: .78rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em;
}
.footer-links { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; font-size: 1rem; }
.footer-links a { color: var(--text); }
.footer-fine { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; margin: 0; }
.topics { color: var(--muted); }

.post-body { padding-bottom: 3rem; }
.post-body h2 { font-size: 1.35rem; margin: 2.5rem 0 .75rem; scroll-margin-top: 1rem; }
.post-body img {
  display: block; max-width: 100%; height: auto; margin: 1.25rem 0;
  border: 1px solid var(--line); border-radius: 10px;
}
.post-body pre {
  margin: 1.25rem 0; padding: 1rem 1.15rem; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--mono); font-size: .85rem; line-height: 1.55;
}
.post-body pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; }

/* Code colours. The classes come from Pygments when tools/build_blog.py builds a post
   (na = property and nf = function are added by the script). Every colour is at least
   4.5:1 against the code background, in both themes. */
.codehilite {
  --tok-keyword: #a8206a; --tok-string: #1a7f37; --tok-number: #6639ba; --tok-operator: #c4262e;
  --tok-func: #7a5900; --tok-builtin: #0b6e80; --tok-comment: #66707a; --tok-regex: #a04f00;
  --tok-punct: #5f5b53;
}
@media (prefers-color-scheme: dark) {
  .codehilite {
    --tok-keyword: #f07bb7; --tok-string: #8bd49c; --tok-number: #b794f6; --tok-operator: #f2616b;
    --tok-func: #e6dc7a; --tok-builtin: #6fd8e0; --tok-comment: #8b949e; --tok-regex: #e8a862;
    --tok-punct: #a6a297;
  }
}
.codehilite .k, .codehilite .kc, .codehilite .kd, .codehilite .kn, .codehilite .kp,
.codehilite .kr, .codehilite .kt, .codehilite .ow { color: var(--tok-keyword); }
.codehilite .s, .codehilite .sa, .codehilite .sb, .codehilite .sc, .codehilite .sd, .codehilite .s1,
.codehilite .s2, .codehilite .se, .codehilite .sh, .codehilite .si, .codehilite .sx, .codehilite .ss { color: var(--tok-string); }
.codehilite .sr { color: var(--tok-regex); }
.codehilite .m, .codehilite .mb, .codehilite .mf, .codehilite .mh, .codehilite .mi,
.codehilite .mo, .codehilite .il { color: var(--tok-number); }
.codehilite .o { color: var(--tok-operator); }
.codehilite .na, .codehilite .nf, .codehilite .fm, .codehilite .nc { color: var(--tok-func); }
.codehilite .nb, .codehilite .bp, .codehilite .nn { color: var(--tok-builtin); }
.codehilite .nt { color: var(--tok-keyword); }
.codehilite .nd, .codehilite .ne { color: var(--tok-func); }
.codehilite .gd { color: var(--tok-operator); }
.codehilite .gi { color: var(--tok-string); }
.codehilite .c, .codehilite .c1, .codehilite .cm, .codehilite .cp, .codehilite .cpf,
.codehilite .ch, .codehilite .cs { color: var(--tok-comment); font-style: italic; }
.codehilite .p { color: var(--tok-punct); }
.codehilite .err { color: inherit; background: none; border: 0; }
.post-body :not(pre) > code { overflow-wrap: anywhere; }
.post-body table { display: block; width: 100%; margin: 1.25rem 0; overflow-x: auto; border-collapse: collapse; font-size: .95rem; }
.post-body th, .post-body td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.post-body th { font-weight: 600; }
.post-end { margin: 2.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line); }
