/* The Intervention: journal layout. nikhilkunche.com/blog
   One content column, 720px, every block shares the same left edge.
   A sticky contents rail sits in the left margin on wide screens only. */
:root {
  --bg: #0a0a0b; --surface: #131315; --surface-2: #1a1a1d; --line: #26262b; --line-2: #35353b;
  --ink: #f0ece4; --ink-2: #cfc9bf; --mute: #8a8680;
  --maroon: #9B2335; --crimson: #c8304a; --link: #e8657a; --cyan: #00d4ff; --green: #33ff88; --yellow: #ffcc00;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --col: 720px; --rail: 200px; --rail-gap: 64px; --gutter: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: 18.5px; line-height: 1.7;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
img { max-width: 100%; height: auto; display: block; }
.hidden { display: none !important; }

/* page grid: [gutter] [column] [gutter]; wide screens add a rail column on the left */
.page { display: grid; grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--col)) minmax(var(--gutter), 1fr); }
.col { grid-column: 2; min-width: 0; }
.full { grid-column: 1 / -1; }
.rail { grid-column: 2; min-width: 0; }

/* progress */
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--crimson); z-index: 50; transition: width .1s linear; }

/* nav */
.topnav { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px var(--gutter); width: 100%;
  max-width: 1120px; margin: 0 auto; font-family: var(--sans); font-size: 13px; letter-spacing: .04em; }
.wordmark { display: inline-flex; align-items: center; text-decoration: none; }
.wordmark-img { height: 44px; width: auto; display: block; }
.journal-name { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--ink-2); text-decoration: none; }
.nav-link { color: var(--mute); text-decoration: none; text-transform: uppercase; font-size: 11px; letter-spacing: .14em; }
.nav-link:hover, .journal-name:hover { color: var(--ink); }

/* one label style for everything that labels */
.eyebrow, .fm-label, .article-meta li span, .series-dir, .ledger-meta, .fig-label, .toc-num, .sec-num, .ref-num, .filter {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); font-weight: 500; }
.eyebrow { margin: 0 0 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--mute); display: inline-block; }
.cat { color: var(--crimson); }
.cat-research { color: #e05a73; } .cat-engineering { color: #4fc3e8; } .cat-clinical { color: #6fd79a; }
.fm-label { display: block; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

/* article head */
.article-head { padding-top: 36px; }
.article-head .headline { max-width: none; }
.headline { font-family: var(--serif); font-weight: 600; font-size: clamp(32px, 4.6vw, 58px); line-height: 1.1; letter-spacing: -.018em; margin: 0 0 28px; color: var(--ink); text-wrap: pretty; }
.byline { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.byline-photo { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-2); }
.byline-text { display: flex; flex-direction: column; font-family: var(--sans); }
.byline-name { font-size: 15px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.orcid { color: #a6ce39; display: inline-flex; }
.byline-aff { font-size: 13.5px; color: var(--mute); }
.article-meta { list-style: none; margin: 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 12px 28px; font-family: var(--sans); font-size: 14px; color: var(--ink); }
.article-meta li span { display: block; margin-bottom: 4px; }
.article-meta li.listen { min-width: 0; }
.listen-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.listen-row .hidden { display: none; }
.listen-btn { font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--ink); background: transparent; border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 12px 4px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; line-height: 1.3; }
.listen-btn::before { content: ''; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent var(--crimson); }
.listen-btn.on::before { width: 8px; height: 10px; border-width: 0 3px; border-color: var(--crimson); border-style: solid; border-top: 0; border-bottom: 0; }
.listen-btn.stop::before { width: 9px; height: 9px; border: 0; background: var(--crimson); }
.listen-btn:hover { border-color: var(--crimson); }
.listen-status { font-family: var(--sans); font-size: 12.5px; color: var(--mute); margin-top: 6px; }
.listen-status:empty { display: none; }
.tldr-btn::before { display: none; }
.tldr-btn { padding: 4px 12px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; }
.tldr { border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); }
.tldr::backdrop { background: rgba(10, 10, 11, .78); }
.tldr-inner { padding: 24px 26px 20px; }
.tldr .fm-label { margin: 0 0 12px; color: var(--crimson); }
.tldr-lead { font-family: var(--serif); font-size: 18px; line-height: 1.5; color: var(--ink); margin: 0 0 14px; }
.tldr ul { margin: 0; padding-left: 18px; font-family: var(--sans); font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.tldr li { margin: 0 0 8px; }
.tldr li::marker { color: var(--crimson); }
.tldr-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* front matter: abstract, highlights, keywords, stacked in the column */
.front-matter { padding-top: 40px; display: flex; flex-direction: column; gap: 36px; }
.abstract p { margin: 0; font-size: 18.5px; line-height: 1.7; color: var(--ink); }
.highlights ul { margin: 0; padding-left: 20px; font-size: 17.5px; line-height: 1.55; color: var(--ink); }
.highlights li { margin: 0 0 10px; padding-left: 4px; }
.highlights li::marker { color: var(--crimson); }
.keywords ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.keywords li { font-family: var(--sans); font-size: 13px; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 12px; background: var(--surface); }

/* contents rail: in column on narrow screens, sticky in the left margin on wide ones */
.rail { font-family: var(--sans); padding-top: 40px; }
.toc summary { cursor: pointer; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a { display: flex; gap: 12px; padding: 5px 0; color: var(--mute); text-decoration: none; font-size: 13.5px; line-height: 1.4; border-left: 2px solid transparent; padding-left: 10px; margin-left: -12px; }
.toc li a:hover { color: var(--ink); }
.toc li a.active { color: var(--ink); border-left-color: var(--crimson); }
.toc-num { color: var(--crimson); min-width: 14px; padding-top: 3px; }
.rail-share { margin-top: 28px; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-ghost { font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); background: transparent; border: 1px solid var(--line-2); border-radius: 4px; padding: 6px 10px; cursor: pointer; }
.share { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); background: transparent; border: 1px solid var(--line-2); border-radius: 50%; padding: 0; cursor: pointer; }
.share:hover, .btn-ghost:hover { border-color: var(--crimson); color: var(--ink); }
.share.copied, .btn-ghost.copied { border-color: var(--green); color: var(--green); }

/* body */
.body { padding-top: 40px; }
.body p { margin: 0 0 1.3em; }
.body strong { font-weight: 600; color: var(--ink); }
.body em { font-style: italic; }
.body q { font-style: italic; quotes: "\201C" "\201D"; }
.body > h2, .refs > h2 { font-family: var(--serif); font-weight: 600; font-size: 25px; line-height: 1.25; letter-spacing: -.01em; margin: 2.3em 0 .8em; color: var(--ink); display: flex; gap: 14px; align-items: baseline; scroll-margin-top: 24px; }
.body > h2:first-child { margin-top: 0; }
.sec-num { color: var(--crimson); flex: none; font-size: 12.5px; }
.body sup { line-height: 0; font-size: 70%; vertical-align: super; }
.body sup a { font-family: var(--mono); color: var(--crimson); text-decoration: none; padding: 0 1px; }
.body sup a:hover { color: var(--ink); }
.body ul, .body ol { padding-left: 1.3em; margin: 0 0 1.3em; }
.body li { margin-bottom: .4em; }
.body blockquote { margin: 1.6em 0; padding: 4px 0 4px 20px; border-left: 2px solid var(--maroon); color: var(--ink-2); font-style: italic; }
.body pre { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; margin: 1.6em 0; color: var(--ink-2); }
.body code { font-family: var(--mono); font-size: .88em; color: var(--cyan); }
.body pre code { color: inherit; }
.body table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 14.5px; margin: 1.6em 0; }
.body th, .body td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.body th { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* figures */
.fig { margin: 2.4em 0; }
.fig img { width: 100%; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.fig figcaption { font-family: var(--sans); font-size: 14px; line-height: 1.55; color: var(--ink-2); margin-top: 12px; }
.fig-label { color: var(--crimson); margin-right: 8px; }

/* references */
.refs { margin-top: 3.2em; border-top: 1px solid var(--line); padding-top: 1.6em; }
.refs h2 { margin-top: 0; }
.refs ol { list-style: none; margin: 0; padding: 0; }
.refs li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 0 6px; align-items: start; font-family: var(--sans); font-size: 14.5px; line-height: 1.55; color: var(--ink-2); padding: 8px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 24px; }
.refs li:target { background: var(--surface); outline: 1px solid var(--line-2); padding-left: 6px; }
.ref-num { color: var(--crimson); padding-top: 3px; }
.refs a.ref-text { color: inherit; text-decoration: underline; text-decoration-color: var(--line-2); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color .12s, text-decoration-color .12s; }
.refs a.ref-text:hover { color: var(--ink); text-decoration-color: var(--crimson); }

/* listen (browser speech): highlight of the block being read */
.reading { background: var(--surface); box-shadow: -14px 0 0 var(--surface), 14px 0 0 var(--surface); border-left: 2px solid var(--crimson); margin-left: -16px; padding-left: 14px; }

/* back matter */
.declarations { margin-top: 2.8em; border-top: 1px solid var(--line); padding-top: 1.6em; font-family: var(--sans); font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.declarations p { margin: 0 0 .9em; }
.declarations strong { color: var(--ink); font-weight: 600; }
.cite-box { margin-top: 2.2em; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; }
.cite-box .fm-label { border-bottom: 0; padding-bottom: 0; margin-bottom: 10px; }
.cite-box p { font-family: var(--sans); font-size: 14px; line-height: 1.6; color: var(--ink-2); margin: 0 0 12px; word-break: break-word; }

/* series nav */
.series-nav { margin-top: 56px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.series-link { display: flex; flex-direction: column; gap: 8px; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; background: var(--surface); }
.series-link:hover { border-color: var(--crimson); }
.series-link.next { text-align: right; }
.series-link.empty { border: 0; background: transparent; }
.series-title { font-family: var(--serif); font-size: 16.5px; line-height: 1.35; color: var(--ink); }

/* comments */
.comments { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); font-family: var(--sans); }
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment-header { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--mute); margin-bottom: 4px; }
.comment-author { color: var(--ink); font-weight: 600; }
.comment-body { font-size: 15px; color: var(--ink-2); white-space: pre-wrap; }
.comment-empty { font-size: 14px; color: var(--mute); padding: 8px 0 16px; }
.comment-form { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.comment-form .row { display: flex; gap: 10px; flex-wrap: wrap; }
.comment-form .row.foot { align-items: center; justify-content: space-between; }
.comment-form input, .comment-form textarea { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line-2); border-radius: 4px; color: var(--ink); font-family: var(--sans); font-size: 14.5px; padding: 10px 12px; }
.comment-form textarea { resize: vertical; }
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--crimson); }
.btn { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--ink); background: var(--maroon); border: 0; border-radius: 4px; padding: 10px 16px; cursor: pointer; }
.btn:hover { background: var(--crimson); }
.btn:disabled { opacity: .5; cursor: default; }
.comment-status { font-size: 13px; color: var(--mute); min-height: 18px; }
.comment-status.error { color: #ff6b6b; } .comment-status.success { color: var(--green); }

/* footer */
.foot { width: 100%; max-width: 1120px; margin: 64px auto 0; padding: 22px var(--gutter) 40px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; color: var(--mute); }
.foot a { color: var(--mute); text-decoration: none; }
.foot a:hover { color: var(--ink); }

/* index */
.index-page { display: block; }
.hero { max-width: 1120px; margin: 0 auto; padding: 28px var(--gutter) 0; }
.hero-trace { position: relative; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.trace { display: block; width: 100%; height: clamp(150px, 20vw, 230px); }
.trace-chart { fill: none; stroke: var(--mute); stroke-width: 1.5; stroke-dasharray: 3 7; }
.trace-true { fill: none; stroke: var(--crimson); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.trace-dots circle { fill: var(--cyan); }
.trace-labels text { font-family: var(--mono); font-size: 11px; fill: var(--mute); letter-spacing: .08em; }
.trace-note { font-family: var(--serif); font-style: italic; font-size: 13.5px; fill: var(--ink-2); }
@media (prefers-reduced-motion: no-preference) {
  .trace-true { stroke-dasharray: 2600; stroke-dashoffset: 2600; animation: trace-draw 2.6s cubic-bezier(.4, 0, .2, 1) .2s forwards; }
  .trace-dots circle { opacity: 0; animation: trace-dot .4s ease-out forwards; }
  .trace-dots circle:nth-child(1) { animation-delay: .3s; } .trace-dots circle:nth-child(2) { animation-delay: .9s; }
  .trace-dots circle:nth-child(3) { animation-delay: 1.5s; } .trace-dots circle:nth-child(4) { animation-delay: 2.1s; }
  .trace-dots circle:nth-child(5) { animation-delay: 2.7s; }
  .trace-note { opacity: 0; animation: trace-dot .6s ease-out 2.4s forwards; }
}
@keyframes trace-draw { to { stroke-dashoffset: 0; } }
@keyframes trace-dot { to { opacity: 1; } }
.hero-text { padding: 40px 0 8px; }
.hero-title { font-family: var(--serif); font-weight: 600; font-size: clamp(44px, 7vw, 84px); line-height: .98; letter-spacing: -.02em; margin: 0 0 14px; color: var(--ink); }
.hero-sub { font-family: var(--serif); font-size: clamp(20px, 2.8vw, 32px); line-height: 1.3; color: var(--ink); margin: 0 0 18px; }
.standfirst { font-size: clamp(17.5px, 1.6vw, 21px); line-height: 1.65; color: var(--ink-2); margin: 0; max-width: 1000px; }

.featured { max-width: 1120px; margin: 48px auto 0; padding: 0 var(--gutter); }
.featured-link { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 36px; align-items: center; text-decoration: none; color: inherit; border-top: 1px solid var(--line); padding-top: 32px; }
.featured-img { width: 100%; height: auto; display: block; border: 1px solid var(--line); background: var(--bg); }
.featured-kicker { font-family: var(--sans); font-size: 13px; color: var(--crimson); margin: 0 0 12px; font-weight: 600; }
.featured-title { font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3vw, 36px); line-height: 1.15; letter-spacing: -.015em; margin: 0 0 14px; color: var(--ink); }
.featured-link:hover .featured-title { color: var(--link); }
.featured-desc { font-size: 17px; line-height: 1.6; color: var(--ink-2); margin: 0 0 16px; }

.archive { max-width: 1120px; margin: 64px auto 0; padding: 0 var(--gutter); }
.archive-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 24px; }
.archive-title { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; color: var(--ink); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter { background: transparent; border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.filter:hover { color: var(--ink); }
.filter.active { color: var(--ink); border-color: var(--crimson); background: rgba(155, 35, 53, .18); }
.cards { list-style: none; margin: 28px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 32px; }
.card.hidden { display: none; }
.card > a { display: block; text-decoration: none; color: inherit; }
.card-img { width: 100%; height: auto; display: block; border: 1px solid var(--line); background: var(--bg); margin-bottom: 14px; }
.card-meta { display: flex; gap: 12px; align-items: center; font-family: var(--sans); font-size: 12.5px; color: var(--mute); margin-bottom: 8px; }
.card-meta .cat { font-family: var(--sans); font-size: 12.5px; letter-spacing: 0; text-transform: none; font-weight: 600; }
.card-title { font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 8px; color: var(--ink); }
.card > a:hover .card-title { color: var(--link); }
.card-desc { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-2); }

.author { max-width: 1120px; margin: 72px auto 0; padding: 32px var(--gutter) 0; display: flex; gap: 24px; align-items: flex-start; border-top: 1px solid var(--line); }
.author-photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--line-2); }
.author-name { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 4px 0 8px; color: var(--ink); }
.author-bio { font-size: 15.5px; line-height: 1.6; color: var(--ink-2); margin: 0 0 10px; max-width: 640px; }
.author-links { display: flex; gap: 18px; margin: 0; font-family: var(--sans); font-size: 13.5px; }
.author-links a { color: var(--mute); text-decoration: none; }
.author-links a:hover { color: var(--ink); }

/* article header rows that hold controls */
.article-meta li.share-item .share-row { gap: 6px; }
.article-meta li.share-item .share { width: 30px; height: 30px; }

/* wide screens: rail in the left margin, on the same row as the body */
@media (min-width: 1180px) {
  .page { grid-template-columns: minmax(var(--gutter), 1fr) var(--rail) var(--rail-gap) minmax(0, var(--col)) minmax(var(--gutter), 1fr); }
  .col { grid-column: 4; }
  .article-head { grid-column: 2 / 5; }
  .rail { grid-column: 2; grid-row: 3 / 5; position: sticky; top: 32px; align-self: start; }
  .article-page .front-matter { grid-row: 3; }
  .article-page .body { grid-row: 4; }
  .fig { margin-left: -40px; margin-right: -40px; }
}
@media (max-width: 1179px) {
  .rail { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: flex-start; }
  .toc { flex: 1 1 320px; }
  .rail-share { margin-top: 0; flex: 0 0 auto; }
}
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px 24px; }
  .featured-link { grid-template-columns: 1fr; gap: 20px; }
}
@media (max-width: 640px) {
  body { font-size: 17.5px; }
  .journal-name { display: none; }
  .series-nav { grid-template-columns: 1fr; }
  .series-link.next { text-align: left; }
  .abstract p, .standfirst { font-size: 17.5px; }
  .highlights ul { font-size: 16.5px; }
  .cards { grid-template-columns: 1fr; gap: 32px; }
  .trace { height: 170px; }
  .wordmark-img { height: 38px; }
  .author { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  body { background: #fff; color: #000; }
  .topnav, .progress, .rail-share, .article-meta li.listen, .article-meta li.tldr-item, .article-meta li.share-item, .comments, .series-nav, .cite-box button { display: none; }
}
