/* samarpreet.dev
   Printed-report typography: serif for prose, mono for anything the machine
   would have written. No motion beyond a colour change on hover. */

:root {
  --paper:    #f7f5f0;
  --sunk:     #efece3;
  --ink:      #16171b;
  --ink-soft: #63656d;
  --rule:     #dbd6ca;
  --accent:   #b0400f;

  --tok-comment: #8a8578;
  --tok-keyword: #9a3412;
  --tok-string:  #40651c;
  --tok-number:  #1e4d6b;
  --tok-name:    #16171b;
  --tok-builtin: #5b4b8a;

  --serif: "Source Serif 4", Charter, Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #0f1013;
    --sunk:     #16181d;
    --ink:      #e4e2dc;
    --ink-soft: #8a8c94;
    --rule:     #272a33;
    --accent:   #ff6a3d;

    --tok-comment: #6c6f78;
    --tok-keyword: #ff8a5c;
    --tok-string:  #9ec96f;
    --tok-number:  #7bb6d9;
    --tok-name:    #e4e2dc;
    --tok-builtin: #b39ddb;
  }
}

/* The toggle wins over the system preference, in both directions. */
:root[data-theme="light"] {
  --paper: #f7f5f0; --sunk: #efece3; --ink: #16171b; --ink-soft: #63656d;
  --rule: #dbd6ca; --accent: #b0400f;
  --tok-comment: #8a8578; --tok-keyword: #9a3412; --tok-string: #40651c;
  --tok-number: #1e4d6b; --tok-name: #16171b; --tok-builtin: #5b4b8a;
}
:root[data-theme="dark"] {
  --paper: #0f1013; --sunk: #16181d; --ink: #e4e2dc; --ink-soft: #8a8c94;
  --rule: #272a33; --accent: #ff6a3d;
  --tok-comment: #6c6f78; --tok-keyword: #ff8a5c; --tok-string: #9ec96f;
  --tok-number: #7bb6d9; --tok-name: #e4e2dc; --tok-builtin: #b39ddb;
}

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

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

body {
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
  max-width: var(--measure);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.62;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* The rule used to hang off the tagline; it lives on the masthead itself now. */
.masthead {
  padding: 3.5rem 0 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.masthead-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--mono);
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: -.02em;
  text-decoration: none;
}
.wordmark::before { content: "▍"; color: var(--accent); margin-right: .45rem; }

.masthead nav {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  font-family: var(--mono);
  font-size: .8125rem;
}
.masthead nav a { color: var(--ink-soft); text-decoration: none; }
.masthead nav a:hover { color: var(--accent); }

#theme {
  border: 0;
  padding: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  line-height: 1;
}
#theme:hover { color: var(--accent); }

/* ------------------------------------------------------------------- index */

.year { margin: 3rem 0; }

.year-label {
  margin: 0 0 .5rem;
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--ink-soft);
}
.year-label em { font-style: normal; color: var(--accent); }

.index { list-style: none; margin: 0; padding: 0; }
.index li { border-top: 1px solid var(--rule); }

.entry {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .7rem 0;
  text-decoration: none;
}
.entry:hover .entry-title { color: var(--accent); }

.entry-date,
.entry-id,
.entry-tags {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.entry-id { color: var(--accent); }
.entry-title { font-size: 1rem; }

/* Table-of-contents leader dots. Nudged up to sit on the baseline. */
.entry-leader {
  flex: 1 1 auto;
  min-width: 1.5rem;
  border-bottom: 1px dotted var(--rule);
  transform: translateY(-.28em);
}

.empty { color: var(--ink-soft); font-style: italic; }

/* -------------------------------------------------------------- document */

.doc-head { margin: 3rem 0 2rem; }

.doc-rubric {
  display: flex;
  gap: 1rem;
  margin: 0 0 .875rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-soft);
}
.doc-id { color: var(--accent); }

.doc-head h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -.015em;
  text-wrap: balance;
}

.doc-summary {
  margin: .875rem 0 0;
  color: var(--ink-soft);
  font-size: 1.0625rem;
}

.doc-tags { margin: 1.125rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.doc-tags a {
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: .15rem .45rem;
  text-decoration: none;
}
.doc-tags a:hover { border-color: var(--accent); color: var(--accent); }

/* Structured header for analysis writeups — hashes, family, tooling. */
.specimen {
  margin: 2rem 0;
  padding: .25rem 1rem;
  border: 1px solid var(--rule);
  background: var(--sunk);
  font-family: var(--mono);
  font-size: .8125rem;
}
.specimen > div {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--rule);
}
.specimen > div:last-child { border-bottom: 0; }
.specimen dt {
  color: var(--accent);
  font-size: .6875rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding-top: .15rem;
}
.specimen dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ prose */

.prose > * + * { margin-top: 1.15em; }

.prose h2, .prose h3, .prose h4 {
  margin: 2.5em 0 .6em;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.prose h2 { font-size: 1.3125rem; }
.prose h3 { font-size: 1.0625rem; }
.prose h4 { font-size: 1rem; color: var(--ink-soft); }

.prose a { text-decoration-color: var(--accent); }

.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li + li { margin-top: .35em; }
.prose li::marker { color: var(--ink-soft); }

.prose blockquote {
  margin-left: 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5em 0;
}

.prose img { max-width: 100%; height: auto; display: block; }

.prose figure { margin: 2em 0; }
.prose figcaption,
.prose img + em {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-soft);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: .8125rem;
}
.prose th, .prose td {
  text-align: left;
  padding: .45rem .6rem .45rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.prose th {
  color: var(--accent);
  font-weight: 500;
  font-size: .6875rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
/* Registry paths and URLs in cells are long enough to push the page wider than
   the viewport; let them break rather than set the table's minimum width. */
.prose td code, .prose th code { overflow-wrap: anywhere; }

.prose sup a { text-decoration: none; color: var(--accent); font-family: var(--mono); }

/* Contents list for long papers. */
.toc {
  margin: 2.5rem 0;
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .8125rem;
}
.toc h2 {
  margin: 0 0 .6rem;
  font-family: var(--mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc li { margin: .3rem 0; display: flex; gap: .7rem; }
.toc li span { color: var(--accent); min-width: 1.6rem; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--accent); }

/* Set-apart note — scope caveats, safety statements. */
.note {
  margin: 1.8em 0;
  padding: .85rem 1rem;
  border: 1px solid var(--rule);
  background: var(--sunk);
  font-size: .9375rem;
}
.note p { margin: 0; }
.note p + p { margin-top: .6em; }
.note strong {
  font-family: var(--mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: .3rem;
}

/* Anchored headings shouldn't hide under nothing — just a little breathing room. */
.prose h2[id], .prose h3[id] { scroll-margin-top: 1.5rem; }

.footnote {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: .875rem;
  color: var(--ink-soft);
}
.footnote hr { display: none; }

/* ------------------------------------------------------------------- code */

code, kbd, samp { font-family: var(--mono); font-size: .8125em; }

.prose :not(pre) > code {
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: .08em .3em;
  overflow-wrap: anywhere;
}

pre {
  margin: 1.6em 0;
  padding: .9rem 1rem;
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  overflow-x: auto;
  line-height: 1.55;
  font-size: .8125rem;
  tab-size: 4;
}
pre code {
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

/* highlight.js tokens, mapped onto the palette above. Loading highlight.js is
   optional — without it code blocks just render in plain mono, which is fine
   for hexdumps and disassembly. */
.hljs-comment, .hljs-quote { color: var(--tok-comment); font-style: italic; }
.hljs-meta, .hljs-meta .hljs-keyword { color: var(--tok-comment); }

.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag,
.hljs-type, .hljs-name, .hljs-tag {
  color: var(--tok-keyword);
}
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute,
.hljs-meta .hljs-string {
  color: var(--tok-string);
}
.hljs-number, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-attr {
  color: var(--tok-number);
}
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section {
  color: var(--tok-name); font-weight: 600;
}
.hljs-built_in, .hljs-symbol, .hljs-variable, .hljs-template-variable,
.hljs-class .hljs-title {
  color: var(--tok-builtin);
}
.hljs-punctuation, .hljs-operator { color: var(--ink-soft); }
.hljs-deletion { color: var(--accent); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

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

.back {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .8125rem;
}
.back a { color: var(--ink-soft); text-decoration: none; }
.back a:hover { color: var(--accent); }

footer {
  display: flex;
  justify-content: space-between;
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-soft);
}
footer a { color: inherit; text-decoration: none; }
footer a:hover { color: var(--accent); }

/* ----------------------------------------------------------------- narrow */

@media (max-width: 40rem) {
  body { font-size: 1rem; padding-bottom: 4rem; }
  .masthead { padding-top: 2.5rem; }
  .doc-head h1 { font-size: 1.5rem; }

  /* The leader-dot row needs horizontal room it no longer has; stack instead. */
  .entry { flex-wrap: wrap; gap: 0 .6rem; }
  .entry-leader { display: none; }
  .entry-title { flex: 1 1 100%; order: 2; margin-top: .15rem; }
  .entry-tags { order: 3; flex: 1 1 100%; margin-top: .25rem; white-space: normal; }

  .specimen > div { grid-template-columns: 1fr; gap: .2rem; }

  /* Backstop: any table still too wide scrolls itself instead of the page. */
  .prose table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
