/* sepehrvahedi.github.io
   A typeset document, not a landing page. Serif for reading, mono for data.
   Six colours, each with one job:
     paper  the page            ink   text
     dim    secondary text      rule  hairlines
     link   things you can follow
     mark   the highlighter (and the "after" bars in figures)                                  */

:root {
  --paper: #f6f4ee; --ink: #191813; --dim: #66645c; --rule: #d3cfc1; --link: #1a3ea6; --mark: #ffe066;
  --stop: #a8281c;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --margin: 11.5rem;          /* the left margin column: section marks and dates live here */
  --measure: 41rem;           /* the reading column */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141410; --ink: #e8e5da; --dim: #99968a; --rule: #35332b; --link: #a9bfff; --mark: #6b5600;
    --stop: #ff9086; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141410; --ink: #e8e5da; --dim: #99968a; --rule: #35332b; --link: #a9bfff; --mark: #6b5600;
  --stop: #ff9086; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0 auto; padding: 0 1.5rem 7rem; max-width: calc(var(--margin) + var(--measure) + 3rem);
  background: var(--paper); color: var(--ink);
  font: 400 1.1875rem/1.55 var(--serif); font-optical-sizing: auto;
  font-variant-numeric: oldstyle-nums proportional-nums; text-rendering: optimizeLegibility;
}
::selection { background: var(--mark); color: var(--ink); }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
b, strong { font-weight: 600; }
mark { color: inherit; background: linear-gradient(transparent 58%, var(--mark) 58%); padding: 0 0.1em; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: 0.4rem 0.7rem; z-index: 10; }

/* ------------------------------------------------------------------ masthead */
.masthead { padding-top: 2.2rem; }
.front { display: flex; justify-content: space-between; gap: 2rem; font: 0.8125rem/1.6 var(--mono); color: var(--dim); }
.front p { margin: 0; }
.front strong { color: var(--ink); font-weight: 600; }
.front-r { text-align: right; }
.toc { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  margin-top: 1.4rem; padding: 0.55rem 0; background: var(--paper); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule);
  font: 0.8125rem/1.5 var(--mono); }
.toc ol { display: flex; flex-wrap: wrap; gap: 0 0.9rem; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.toc li { counter-increment: s; padding: 0; margin: 0; }
.toc li a { color: var(--ink); text-decoration: none; }
.toc li a::before { content: counter(s) " "; color: var(--dim); }
.toc li a:hover, .toc li a[aria-current] { text-decoration: underline; text-underline-offset: 0.3em; }
.tools { display: flex; gap: 0.75rem; margin: 0; white-space: nowrap; }
.tools button { font: inherit; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 0.16em; }

/* ------------------------------------------------------------------ sections: margin label + body */
section { display: grid; grid-template-columns: var(--margin) minmax(0, var(--measure)); padding-top: 3.4rem; }
.label { margin: 0.42rem 0 0; font: 500 0.8125rem/1.5 var(--mono); letter-spacing: 0.02em; color: var(--dim); }
.label span { color: var(--ink); margin-right: 0.35em; }
.body > :first-child { margin-top: 0; }
p { margin: 0 0 1rem; }
h1 { margin: 0 0 1.5rem; font: 500 2.5rem/1.1 var(--serif); letter-spacing: -0.018em; text-wrap: balance; }
h3 { margin: 0 0 0.4rem; font: 600 1.1875rem/1.35 var(--serif); }
.org { font-weight: 400; color: var(--dim); }
.org a { color: inherit; }
.aside, .more { color: var(--dim); font-size: 1.0625rem; }
.lede { font-size: 1.4rem; line-height: 1.35; text-wrap: balance; }
.portrait { float: right; margin: 0.2rem 0 0.8rem 1.5rem; }
.portrait img { display: block; width: 7.5rem; height: 7.5rem; object-fit: cover; filter: grayscale(1) contrast(1.05); }

/* log entries: the date sits in the margin, level with its heading (one line below the section label) */
.log { padding-top: 2.3rem; }
.log article { position: relative; margin-bottom: 1.9rem; }
.when { position: absolute; right: 100%; top: 0.3rem; width: var(--margin); margin: 0; padding-right: 1.5rem;
  font: 0.8125rem/1.5 var(--mono); color: var(--dim); }
ul { margin: 0; padding: 0; list-style: none; }
li { position: relative; padding-left: 1.15rem; margin-bottom: 0.35rem; }
ul > li::before { content: "–"; position: absolute; left: 0; color: var(--dim); }

/* ------------------------------------------------------------------ the results table */
.scroll { overflow-x: auto; margin: 1.4rem 0 2rem; }
.results { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 1.0625rem; line-height: 1.45; }
.results th { text-align: left; font: 500 0.75rem/1.5 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim);
  padding: 0 1rem 0.45rem 0; border-bottom: 1px solid var(--ink); }
.results td { vertical-align: top; padding: 0.8rem 1rem 0.8rem 0; border-bottom: 1px solid var(--rule); }
.results td:first-child { width: 9.5rem; color: var(--dim); font-size: 1rem; }
.results td:last-child { width: 13rem; padding-right: 0; color: var(--dim); font-size: 1rem; }
.results .n { display: block; color: var(--ink); font: 600 1.25rem/1.2 var(--mono); font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.02em; white-space: nowrap; background: linear-gradient(transparent 62%, var(--mark) 62%); width: fit-content; padding: 0 0.12em; }

/* ------------------------------------------------------------------ figures */
.fig { margin: 1.6rem 0 0.4rem; }
.fig svg { display: block; width: 100%; height: auto; overflow: visible; }
.fig text { font: 13px var(--mono); fill: var(--dim); }
.fig .v text { fill: var(--ink); }
.fig .v .on { fill: var(--ink); font-weight: 600; }
.fig .bar { fill: var(--mark); stroke: var(--ink); stroke-width: 1; }
.fig .bar.dim { fill: var(--paper); }
.fig .axis line { stroke: var(--ink); stroke-width: 1; }
.fig .axis .grid { stroke: var(--rule); stroke-dasharray: 2 3; }
figcaption { margin-top: 0.7rem; font: 0.8125rem/1.55 var(--mono); color: var(--dim); }
figcaption b { color: var(--ink); font-weight: 600; }

/* figure 3: the rate limiter */
.sim { border-top: 1px solid var(--rule); padding-top: 1.1rem; }
.sim-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.sim button { font: 500 0.875rem var(--mono); color: var(--paper); background: var(--ink); border: 1px solid var(--ink); padding: 0.5rem 0.9rem; cursor: pointer; }
.sim button:active { transform: translateY(1px); }
.bucket { display: flex; gap: 4px; }
.bucket i { width: 1.25rem; height: 1.25rem; border: 1px solid var(--ink); background: linear-gradient(var(--mark), var(--mark)) no-repeat left / calc(var(--f, 1) * 100%) 100%; }
.sim output { font: 0.8125rem var(--mono); color: var(--dim); }
.sim-log { margin: 0.9rem 0 0; padding: 0; list-style: none; font: 0.8125rem/1.6 var(--mono); }
.sim-log.live { min-height: 6.5rem; }
.sim-log li { padding: 0; margin: 0; }
.sim-log li::before { content: none; }
.sim-log .hint { color: var(--dim); }
.sim-log .s429 { color: var(--stop); }
.sim-log time { color: var(--dim); margin-right: 1ch; white-space: pre; }

/* ------------------------------------------------------------------ facts, contact, colophon */
.facts { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.7rem 1.2rem; margin: 0; font-size: 1.0625rem; }
.facts dt { font: 0.8125rem/1.9 var(--mono); color: var(--dim); }
.facts dd { margin: 0; }
.links { display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; font: 0.9375rem var(--mono); }
.colophon { margin: 4.5rem 0 0 var(--margin); max-width: var(--measure); padding-top: 1rem; border-top: 1px solid var(--ink);
  font: 0.8125rem/1.7 var(--mono); color: var(--dim); }
.colophon p { margin: 0 0 0.5rem; }
.colophon b { color: var(--ink); font-weight: 600; }
kbd, code { font: inherit; font-family: var(--mono); }
kbd { border: 1px solid var(--rule); border-bottom-width: 2px; padding: 0 0.35em; color: var(--ink); }

/* ------------------------------------------------------------------ the command line */
.cmd { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; padding: 0.55rem 1.5rem 0.7rem; background: var(--ink); color: var(--paper);
  font: 0.875rem/1.5 var(--mono); }
.cmd[hidden] { display: none; }
.cmd label { display: flex; gap: 0.5ch; max-width: calc(var(--margin) + var(--measure)); margin: 0 auto; }
.cmd input { flex: 1; min-width: 0; font: inherit; color: inherit; background: none; border: 0; outline: 0; padding: 0; caret-color: var(--mark); }
.cmd input::placeholder { color: color-mix(in srgb, var(--paper) 45%, transparent); }
.cmd-out { max-width: calc(var(--margin) + var(--measure)); margin: 0 auto 0.3rem; white-space: pre-wrap; color: color-mix(in srgb, var(--paper) 75%, transparent); }
.cmd-out:empty { display: none; }
.cmd-out b { color: var(--paper); font-weight: 500; }

/* ------------------------------------------------------------------ narrow screens: the margin folds into the column */
@media (max-width: 56rem) {
  body { font-size: 1.125rem; padding: 0 1.15rem 6rem; }
  section { display: block; padding-top: 2.6rem; }
  .log { padding-top: 0; }
  .label { margin: 0 0 0.9rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--rule); }
  .when { position: static; width: auto; padding: 0; margin-bottom: 0.15rem; }
  .colophon { margin-left: 0; }
  h1 { font-size: 1.95rem; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 0.8rem; }
  .front { flex-direction: column; gap: 0.5rem; }
  .front-r { text-align: left; }
  .toc { flex-direction: column; gap: 0.35rem; }
  .keys { display: none; }
  .portrait img { width: 5.5rem; height: 5.5rem; }
  .cmd { padding-left: 1.15rem; padding-right: 1.15rem; }
  /* the results table becomes a list: number, what changed, how I know */
  .results { min-width: 0; }
  .results thead { display: none; }
  .results, .results tbody, .results tr, .results td { display: block; width: auto; }
  .results tr { padding: 0.9rem 0; border-bottom: 1px solid var(--rule); }
  .results tr:first-child { border-top: 1px solid var(--ink); }
  .results td, .results td:first-child, .results td:last-child { width: auto; padding: 0 0 0.35rem; border: 0; }
  .results td:last-child::before { content: "How I know: "; font: 0.75rem var(--mono); }
}

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ------------------------------------------------------------------ paper: this page prints as a two-page CV */
@media print {
  :root { --paper: #fff; --ink: #000; --dim: #444; --rule: #bbb; --link: #000; --mark: #e6e6e6; }
  html { font-size: 11.5px; }
  body { max-width: none; padding: 0; }
  .toc, .tools, .cmd, .sim, .keys, .skip, .portrait { display: none !important; }
  section { padding-top: 1.6rem; grid-template-columns: 8.5rem 1fr; }
  .when { width: 8.5rem; }
  a { text-decoration: none; }
  article, tr, figure { break-inside: avoid; }
  .colophon { margin-left: 8.5rem; }
}
