/* sites.tanmoysarkar.me design system. One file for every page.
   Light and dark follow the system. html.dark or html.light force one. */

:root {
  color-scheme: light dark;
  --bg: #ffffff; --text: #1c1d1f; --muted: #646a72; --faint: #9a9fa6;
  --line: #e7e8eb; --line-strong: #d3d6db; --soft: #f6f7f8; --soft-2: #edeff2;
  --accent: #2b5fd9; --ok: #1a7f45; --warn: #a35d00; --bad: #c0352b;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  --s1: #4f7be8; --s2: #e8894f; --s3: #3fa66b; --s4: #d65a5a; --s5: #8a6fd6; --s6: #2fa3a3; --s7: #c99a1e; --s8: #8c9097;
}
@media (prefers-color-scheme: dark) { :root:not(.light) {
  --bg: #111214; --text: #e7e8ea; --muted: #9ba1a9; --faint: #6d737b;
  --line: #25282d; --line-strong: #363a40; --soft: #191b1e; --soft-2: #212428;
  --accent: #86aaff; --ok: #5fcf8a; --warn: #f0ad54; --bad: #ff8b80;
  --s1: #7c9ef0; --s2: #f0a271; --s3: #62c18a; --s4: #e88080; --s5: #a891e6; --s6: #4fc2c2; --s7: #e0b84a; --s8: #a4a8ae;
} }
:root.dark {
  --bg: #111214; --text: #e7e8ea; --muted: #9ba1a9; --faint: #6d737b;
  --line: #25282d; --line-strong: #363a40; --soft: #191b1e; --soft-2: #212428;
  --accent: #86aaff; --ok: #5fcf8a; --warn: #f0ad54; --bad: #ff8b80;
  --s1: #7c9ef0; --s2: #f0a271; --s3: #62c18a; --s4: #e88080; --s5: #a891e6; --s6: #4fc2c2; --s7: #e0b84a; --s8: #a4a8ae;
}

/* Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 var(--sans); -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* Frame: top bar, article, contents */
.top { max-width: 1072px; margin: 0 auto; padding: 20px 24px; display: flex; gap: 8px; font-size: 14px; color: var(--faint); }
.top a { color: var(--muted); text-decoration: none; }
.top a:hover { color: var(--text); }
.layout { max-width: 1072px; margin: 0 auto; padding: 0 24px 112px; display: grid; grid-template-columns: minmax(0, 680px) 200px; gap: 72px; justify-content: center; }
article { min-width: 0; }
article > :first-child { margin-top: 24px; }
.toc { position: sticky; top: 32px; align-self: start; margin-top: 40px; max-height: calc(100vh - 64px); overflow-y: auto; font-size: 13.5px; line-height: 1.45; }
.toc a { display: block; padding: 5px 0 5px 12px; border-left: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); }
.toc a.on { color: var(--text); border-left-color: var(--text); }
details.contents { display: none; }

/* Type */
h1 { font-size: 34px; line-height: 1.18; font-weight: 680; letter-spacing: -.022em; margin: 24px 0 12px; text-wrap: balance; }
h2 { font-size: 22px; line-height: 1.3; font-weight: 650; letter-spacing: -.012em; margin: 56px 0 12px; scroll-margin-top: 24px; text-wrap: balance; }
h3 { font-size: 17px; line-height: 1.4; font-weight: 650; margin: 32px 0 8px; scroll-margin-top: 24px; }
h4 { font-size: 15px; font-weight: 650; margin: 24px 0 6px; }
h2 + h3 { margin-top: 16px; }
p, ul, ol, dl, pre, table, figure, blockquote, details { margin: 0 0 16px; }
ul, ol { padding-left: 22px; }
li { padding-left: 2px; }
li + li { margin-top: 6px; }
li > ul, li > ol { margin: 6px 0 0; }
li::marker { color: var(--faint); }
b, strong { font-weight: 620; }
small, .small { font-size: 14px; }
.muted { color: var(--muted); }
.lead { font-size: 19px; line-height: 1.55; color: var(--muted); margin: 0 0 14px; text-wrap: pretty; }
.meta { font-size: 14px; color: var(--faint); margin: 0 0 32px; font-variant-numeric: tabular-nums; }
.meta a { color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
blockquote { margin-left: 0; padding-left: 16px; border-left: 2px solid var(--line-strong); color: var(--muted); }
img, video { max-width: 100%; height: auto; border-radius: 8px; }
kbd { font: 12.5px var(--mono); padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; }

/* Code */
code { font: .875em/1.5 var(--mono); background: var(--soft); padding: .12em .38em; border-radius: 5px; }
pre { font: 13.5px/1.6 var(--mono); background: var(--soft); padding: 14px 18px; border-radius: var(--radius); overflow-x: auto; tab-size: 2; }
pre code { font: inherit; background: none; padding: 0; }

/* Summary and status: the first screen */
.summary { list-style: none; background: var(--soft); border-radius: var(--radius); padding: 18px 22px; margin: 0 0 32px; }
.summary li { position: relative; padding-left: 18px; }
.summary li::before { content: ""; position: absolute; left: 0; top: .72em; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.status { margin: 0 0 32px; border-top: 1px solid var(--line); }
.status > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.55; }
.status dt { font-weight: 620; }
.status dd { margin: 0; }
.status .done dt { color: var(--ok); }
.status .next dt { color: var(--accent); }
.status .open dt { color: var(--warn); }
.status .blocked dt { color: var(--bad); }

/* Notes */
.note { border-left: 3px solid var(--accent); background: var(--soft); border-radius: 0 10px 10px 0; padding: 12px 16px; margin: 20px 0; font-size: 15px; line-height: 1.6; }
.note > :last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--warn); }
.note.bad { border-left-color: var(--bad); }
.note.ok { border-left-color: var(--ok); }

/* Tags: color only for meaning */
.tag { display: inline-block; font-size: 12.5px; line-height: 1.5; font-weight: 560; padding: 0 7px; border-radius: 6px; background: var(--soft-2); color: var(--muted); white-space: nowrap; vertical-align: .08em; }
.tag.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tag.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.tag.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.tag.info { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* Tables. The build wraps each table in .table so it scrolls on a phone. */
.table { overflow-x: auto; margin: 16px 0 24px; -webkit-overflow-scrolling: touch; }
.table > table { margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 9px 16px 9px 0; border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { padding-right: 0; }
thead th, tr:first-child > th { font-size: 13px; font-weight: 600; color: var(--muted); border-bottom-color: var(--line-strong); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Number tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 32px; padding: 0; list-style: none; }
.stats > * { background: var(--soft); border-radius: 10px; padding: 14px 16px; margin: 0; }
.stats b { display: block; font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stats span { font-size: 13px; color: var(--muted); }

/* Columns: before and after, option A and B. They stack on a phone. */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 16px 0 24px; }
.cols > * { min-width: 0; }
.cols > * > :last-child { margin-bottom: 0; }
.card { background: var(--soft); border-radius: var(--radius); padding: 16px 18px; }
.card > h3:first-child, .card > h4:first-child { margin-top: 0; }

/* Details */
details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
details + details { margin-top: -17px; }
summary { cursor: pointer; padding: 11px 0; font-weight: 560; list-style: none; display: flex; gap: 10px; align-items: baseline; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; flex: none; width: 6px; height: 6px; border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint); transform: translateY(-2px) rotate(-45deg); transition: transform .15s; }
details[open] > summary::before { transform: translateY(-3px) rotate(45deg); }
details > :not(summary) { margin-left: 16px; }
details[open] > :last-child { margin-bottom: 16px; }

/* Figures and Pele diagrams */
figure { margin: 24px 0 28px; }
figcaption { font-size: 13.5px; line-height: 1.5; color: var(--muted); margin-top: 10px; text-align: center; text-wrap: balance; }
.diagram {
  background: var(--soft); border-radius: var(--radius); padding: 24px 20px; overflow-x: auto; text-align: center; -webkit-overflow-scrolling: touch;
  --pele-bg: var(--soft); --pele-fg: var(--text); --pele-fg-on-light: #1c1d1f; --pele-fg-on-dark: #ffffff;
  --pele-muted: var(--muted); --pele-line: var(--faint); --pele-surface: var(--bg); --pele-surface-alt: var(--soft-2);
  --pele-border: var(--line-strong); --pele-accent: var(--accent); --pele-critical: var(--bad); --pele-error: var(--bad);
  --pele-font: var(--sans); --pele-font-mono: var(--mono); --pele-radius: 8px;
  --pele-title-weight: 650; --pele-heading-weight: 620; --pele-bold-weight: 620;
  --pele-series-1: var(--s1); --pele-series-2: var(--s2); --pele-series-3: var(--s3); --pele-series-4: var(--s4);
  --pele-series-5: var(--s5); --pele-series-6: var(--s6); --pele-series-7: var(--s7); --pele-series-8: var(--s8);
}
.diagram svg { display: inline-block; max-width: 100%; height: auto; vertical-align: top; }
.diagram .narrow { display: none; }
.diagram .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.diagram .scroll svg { max-width: none !important; width: max(100%, min(var(--w), 540px)); }
.diagram .narrow.scroll svg { width: max(100%, min(var(--w), 440px)); }
/* class node hl in Mermaid marks the part the text talks about */
.pele .hl > :is(rect, polygon, circle, ellipse, path) { stroke: var(--pele-accent) !important; stroke-width: 1.5px !important; }
.pele .hl .pele-label { fill: var(--pele-accent) !important; }
.pele .pele-cluster-label { fill: var(--pele-muted); }

/* State charts. Group colors come from the statechart command: class sN teal.
   The marks come last, so a mark shows over a group color. */
.statechart { --tint: 14%; }
.pele :is(.blue, .orange, .purple, .yellow, .teal, .tan, .pink, .gray) > rect { fill: color-mix(in srgb, var(--c) var(--tint, 14%), var(--pele-surface)) !important; stroke: color-mix(in srgb, var(--c) 45%, var(--pele-border)) !important; }
.blue { --c: var(--s1); } .orange { --c: var(--s2); } .teal { --c: var(--s6); } .purple { --c: var(--s5); }
.yellow { --c: var(--s7); } .tan { --c: #a0826d; } .pink { --c: #d16ba5; } .gray { --c: var(--s8); }
.pele .bugPath > rect { stroke: var(--accent) !important; stroke-width: 2px !important; }
.pele .repeats > rect { stroke: var(--s5) !important; stroke-width: 2px !important; stroke-dasharray: 5 3; }
.pele .mayBreak > rect { fill: color-mix(in srgb, var(--warn) 14%, var(--pele-surface)) !important; stroke: var(--warn) !important; stroke-width: 2px !important; }
.pele .mayBreak text { fill: var(--warn) !important; }
.pele .breaks > rect { fill: color-mix(in srgb, var(--bad) 13%, var(--pele-surface)) !important; stroke: var(--bad) !important; stroke-width: 2px !important; }
.pele .breaks text { fill: var(--bad) !important; font-weight: 600; }
.pele .pele-state-start circle { fill: var(--pele-fg); stroke: none; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; list-style: none; padding: 0; margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 7px; margin: 0; padding: 0; }
.legend .k { width: 14px; height: 10px; border-radius: 3px; border: 1px solid var(--line-strong); background: var(--bg); }
.legend .k:is(.blue, .orange, .purple, .yellow, .teal, .tan, .pink, .gray) { background: color-mix(in srgb, var(--c) 22%, var(--bg)); border-color: color-mix(in srgb, var(--c) 50%, var(--line-strong)); }
.legend .k.breaks { background: color-mix(in srgb, var(--bad) 15%, var(--bg)); border: 1.5px solid var(--bad); }
.legend .k.mayBreak { background: color-mix(in srgb, var(--warn) 15%, var(--bg)); border: 1.5px solid var(--warn); }
.legend .k.bugPath { border: 1.5px solid var(--accent); }
.legend .k.repeats { border: 1.5px dashed var(--s5); }

/* A path through states: the steps to a bug, or a scenario */
.trace { list-style: none; padding: 0; margin: 16px 0 24px; counter-reset: step; }
.trace li { position: relative; counter-increment: step; padding: 0 0 18px 40px; margin: 0; }
.trace li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%; background: var(--soft-2); color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 24px; text-align: center; }
.trace li::after { content: ""; position: absolute; left: 11.5px; top: 30px; bottom: 4px; width: 1px; background: var(--line-strong); }
.trace li:last-child { padding-bottom: 0; }
.trace li:last-child::after { display: none; }
.trace b { display: block; font-weight: 620; }
.trace span { display: block; font-size: 14.5px; color: var(--muted); }
.trace .bad::before { background: var(--bad); color: var(--bg); }
.trace .bad b { color: var(--bad); }

/* End of page: sources and changelog */
.end { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.6; color: var(--muted); }
.end h2 { font-size: 14px; letter-spacing: 0; margin: 0 0 6px; color: var(--text); }
.end ul { padding-left: 18px; margin-bottom: 24px; }
.end li + li { margin-top: 3px; }

/* Home and section pages: a plain index of date and title */
.home { max-width: 640px; margin: 0 auto; padding: 88px 24px 120px; }
.home h1 { font-size: 21px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.home h1 a { color: inherit; text-decoration: none; }
.home header p { margin: 4px 0 0; color: var(--muted); }
.sections { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 20px; font-size: 15px; }
.sections a { color: var(--muted); text-decoration: none; }
.sections a:hover { color: var(--text); }
.sections a[aria-current] { color: var(--text); font-weight: 600; }
.sections i { font-style: normal; font-weight: 400; color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }
.index { margin-top: 48px; }
.index h2 { font-size: 14px; line-height: 1.4; font-weight: 600; letter-spacing: 0; color: var(--faint); margin: 32px 0 6px; }
.index h2:first-child { margin-top: 0; }
.index a { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 7px 0; color: var(--text); text-decoration: none; }
.index a:hover span { color: var(--accent); }
.index time { font-size: 14px; color: var(--faint); font-variant-numeric: tabular-nums; }
.index span { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home .foot { margin-top: 56px; font-size: 14px; color: var(--faint); }
.home .foot a { color: var(--muted); }

/* Narrow screens */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 680px); }
  .toc { display: none; }
  details.contents { display: block; margin: 0 0 32px; font-size: 15px; }
  details.contents ol { margin: 0 0 14px 16px; padding-left: 18px; }
  details.contents li + li { margin-top: 3px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; line-height: 1.65; }
  .top, .layout, .home { padding-left: 16px; padding-right: 16px; }
  .top { padding-top: 16px; padding-bottom: 8px; }
  h1 { font-size: 27px; }
  h2 { font-size: 20px; margin-top: 44px; }
  .lead { font-size: 17px; }
  .summary { padding: 14px 16px; }
  .status > div { grid-template-columns: 64px minmax(0, 1fr); }
  pre { border-radius: 10px; padding: 12px 14px; font-size: 13px; }
  .diagram { padding: 20px 8px; margin-left: -16px; margin-right: -16px; border-radius: 0; }
  .diagram .wide-only { display: none; }
  .diagram .narrow { display: block; }
  .home { padding-top: 48px; padding-bottom: 80px; }
  .index a { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 9px 0; }
}
@media print {
  .top, .toc, details.contents { display: none; }
  .layout { display: block; padding: 0; }
  .diagram, .summary, pre, .note { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
