/* ==========================================================================
   Computer Vision History and ResNet notes
   ========================================================================== */

:root {
  --bg: #fbfaf8;
  --bg-raised: #ffffff;
  --bg-sunken: #f3f1ed;
  --ink: #1c1a17;
  --ink-soft: #4a463f;
  --ink-faint: #7d776c;
  --rule: #e2ded6;
  --rule-strong: #cdc7bb;
  --accent: #9a3412;
  --accent-soft: #c2410c;
  --accent-wash: #fdf0e8;
  --link: #1d4ed8;
  --residual: #0f766e;
  --plain: #b91c1c;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --measure: 39rem;
  --wide: 72rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --bg-raised: #1e1d16;
    --bg-sunken: #12110c;
    --ink: #eeeae1;
    --ink-soft: #c3bdb0;
    --ink-faint: #8f887a;
    --rule: #33311f;
    --rule-strong: #4a4732;
    --accent: #fb923c;
    --accent-soft: #fdba74;
    --accent-wash: #2a1d12;
    --link: #93b4fd;
    --residual: #5eead4;
    --plain: #fca5a5;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

.masthead {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8125rem;
}

.masthead__home {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.masthead__home:hover { color: var(--accent); }

.masthead__crumbs {
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masthead__spacer { flex: 1; }

.masthead__nav {
  display: flex;
  gap: 0.9rem;
}

.masthead__nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 1.5px solid transparent;
}

.masthead__nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.masthead__nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

@media (max-width: 720px) {
  .masthead__crumbs, .masthead__nav { display: none; }
}

/* ------------------------------------------------------------------ layout */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: clamp(1.5rem, 5vw, 4rem);
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(1.75rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2.5rem) 5rem;
  align-items: start;
}

.shell--plain { grid-template-columns: minmax(0, 1fr); }

article { min-width: 0; }

/* -------------------------------------------------------------------- rail */

.rail {
  position: sticky;
  top: 4.5rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding-left: 1.1rem;
  border-left: 1px solid var(--rule);
}

.rail__title {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 0 0 0.7rem;
  font-weight: 650;
}

.rail ol { list-style: none; margin: 0; padding: 0; }
.rail li { margin: 0 0 0.1rem; }

.rail a {
  display: block;
  padding: 0.22rem 0;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 0.6rem;
  margin-left: -0.7rem;
}

.rail a:hover { color: var(--ink); }
.rail a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.rail .lvl-3 a { padding-left: 1.5rem; font-size: 0.75rem; color: var(--ink-faint); }
.rail .lvl-3 a:hover { color: var(--ink-soft); }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
}

/* ---------------------------------------------------------------- typography */

.eyebrow {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.9rem, 4.6vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.021em;
  margin: 0 0 0.6rem;
  font-weight: 600;
}

h2 {
  font-size: clamp(1.3rem, 2.8vw, 1.6rem);
  line-height: 1.25;
  letter-spacing: -0.014em;
  margin: 3.1rem 0 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
}

h3 {
  font-size: 1.1rem;
  line-height: 1.34;
  margin: 2.1rem 0 0.6rem;
  font-weight: 650;
  letter-spacing: -0.008em;
}

h4 {
  font-size: 0.96rem;
  margin: 1.5rem 0 0.4rem;
  font-family: var(--sans);
  font-weight: 650;
  color: var(--ink-soft);
}

p { margin: 0 0 1.15rem; max-width: var(--measure); }
article > ul, article > ol, article > blockquote { max-width: var(--measure); }

.lede {
  font-size: 1.16rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 36rem;
}

.byline {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink-faint);
  margin: 0 0 2.4rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

ul, ol { padding-left: 1.3rem; margin: 0 0 1.15rem; }
li { margin: 0 0 0.45rem; }
li > ul, li > ol { margin-top: 0.45rem; }

strong { font-weight: 680; }

blockquote {
  margin: 1.6rem 0;
  padding: 0.1rem 0 0.1rem 1.15rem;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.75rem 0; }

.heading-anchor {
  float: left;
  margin-left: -1.15rem;
  width: 1.15rem;
  color: var(--rule-strong);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.12s;
}
h2:hover .heading-anchor, h3:hover .heading-anchor { opacity: 1; }

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

code, kbd, samp {
  font-family: var(--mono);
  font-size: 0.855em;
  font-variant-ligatures: none;
}

:not(pre) > code {
  background: var(--bg-sunken);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1em 0.34em;
  white-space: nowrap;
}

/* long file paths must never widen the page */
.byline code,
.card code { white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 620px) {
  :not(pre) > code { white-space: normal; overflow-wrap: anywhere; }
}

pre {
  margin: 1.5rem 0;
  padding: 1.05rem 1.2rem;
  background: var(--bg-sunken);
  border: 1px solid var(--rule);
  border-radius: 9px;
  overflow-x: auto;
  font-size: 0.855rem;
  line-height: 1.62;
  -webkit-overflow-scrolling: touch;
}

pre code {
  font-size: 1em;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

.codeblock { margin: 1.5rem 0; }
.codeblock pre { margin: 0; border-radius: 0 0 9px 9px; border-top: 0; }

.codeblock__bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0.9rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 9px 9px 0 0;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.codeblock__lang { font-weight: 650; }
.codeblock__file { text-transform: none; letter-spacing: 0; font-family: var(--mono); }
.codeblock__copy {
  margin-left: auto;
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--ink-faint);
  padding: 0.12rem 0.5rem;
  cursor: pointer;
}
.codeblock__copy:hover { color: var(--ink); border-color: var(--rule-strong); }

/* highlight.js, tuned to the page palette */
.hljs-comment, .hljs-quote { color: var(--ink-faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #9333ea; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #047857; }
.hljs-number, .hljs-built_in { color: #b45309; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #1d4ed8; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-params { color: var(--ink); }
.hljs-meta { color: var(--ink-faint); }
.hljs-deletion { color: #b91c1c; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

@media (prefers-color-scheme: dark) {
  .hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #d8b4fe; }
  .hljs-string, .hljs-regexp, .hljs-addition { color: #6ee7b7; }
  .hljs-number, .hljs-built_in { color: #fcd34d; }
  .hljs-title, .hljs-title.function_, .hljs-section { color: #93c5fd; }
}

/* ------------------------------------------------------------------ tables */

.table-scroll {
  margin: 1.6rem 0;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--bg-raised);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.83rem;
  line-height: 1.45;
}

thead th {
  position: relative;
  text-align: left;
  font-weight: 650;
  font-size: 0.7rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.6rem 0.85rem;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}

tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-wash); }
tbody td:first-child { font-weight: 600; color: var(--ink); }
table code { white-space: nowrap; }

/* --------------------------------------------------------------- figures */

.figure {
  margin: 2.2rem 0;
  padding: 1.15rem 1.25rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 11px;
}

.figure--wide { max-width: none; }

.figure__head {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-bottom: 0.2rem;
  font-family: var(--sans);
}

.figure__tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.figure__title { font-size: 0.875rem; font-weight: 650; color: var(--ink); }

.figure__note {
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-faint);
  margin: 0.7rem 0 0;
  max-width: 44rem;
}

.figure__body { margin-top: 0.9rem; }

.figure svg { display: block; width: 100%; height: auto; overflow: visible; }

.figure__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.3rem;
  align-items: center;
  margin: 0.9rem 0 0.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
}

.ctl { display: flex; align-items: center; gap: 0.5rem; }
.ctl > label { color: var(--ink-faint); white-space: nowrap; }
.ctl output { font-family: var(--mono); font-weight: 650; color: var(--ink); min-width: 3.4rem; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 8.5rem;
  height: 3px;
  background: var(--rule-strong);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-raised);
  box-shadow: 0 0 0 1px var(--rule-strong);
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg-raised);
}

select, input[type="number"] {
  font-family: var(--sans);
  font-size: 0.78rem;
  padding: 0.24rem 0.45rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  max-width: 100%;
}

.ctl { min-width: 0; max-width: 100%; }
.ctl select { flex: 0 1 auto; min-width: 0; }

.toggle-group { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; }
.toggle-group button {
  font-family: var(--sans);
  font-size: 0.76rem;
  padding: 0.24rem 0.7rem;
  background: var(--bg);
  color: var(--ink-soft);
  border: 0;
  border-right: 1px solid var(--rule-strong);
  cursor: pointer;
}
.toggle-group button:last-child { border-right: 0; }
.toggle-group button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 650; }

.legend { display: flex; flex-wrap: wrap; gap: 0.45rem 1.1rem; font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.7rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { width: 0.8rem; height: 0.8rem; border-radius: 2px; flex: none; }

.readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
}
.readout div { min-width: 0; }
.readout dt { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin-bottom: 0.2rem; }
.readout dd { margin: 0; font-family: var(--mono); font-size: 1.02rem; font-weight: 650; color: var(--ink); letter-spacing: -0.02em; }
.readout dd small { font-family: var(--sans); font-size: 0.68rem; font-weight: 500; color: var(--ink-faint); display: block; letter-spacing: 0; }

/* ------------------------------------------------------------------ callout */

.callout {
  margin: 1.8rem 0;
  padding: 0.95rem 1.15rem;
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 9px;
  font-size: 0.945rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout__label {
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 0.35rem;
}

/* --------------------------------------------------------------- home page */

.hero { max-width: 40rem; margin-bottom: 1rem; }

.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: 0.9rem;
  margin: 1.8rem 0 1rem;
  padding: 0;
  list-style: none;
  max-width: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.05rem 1.15rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 11px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.14s, transform 0.14s;
  margin: 0;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card__n { font-family: var(--mono); font-size: 0.7rem; color: var(--accent); font-weight: 700; letter-spacing: 0.05em; }
.card__t { font-size: 1.04rem; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
.card__d { font-family: var(--sans); font-size: 0.8rem; line-height: 1.5; color: var(--ink-faint); }
.card__meta { font-family: var(--sans); font-size: 0.7rem; color: var(--ink-faint); margin-top: 0.3rem; padding-top: 0.5rem; border-top: 1px solid var(--rule); }

/* ------------------------------------------------------------------- pager */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-top: 3.5rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

.pager a {
  padding: 0.85rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 9px;
  text-decoration: none;
  color: inherit;
  font-family: var(--sans);
}
.pager a:hover { border-color: var(--accent); }
.pager__dir { display: block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-faint); margin-bottom: 0.2rem; }
.pager__t { font-size: 0.875rem; font-weight: 600; line-height: 1.35; }
.pager__next { text-align: right; grid-column: 2; }

@media (max-width: 560px) {
  .pager { grid-template-columns: 1fr; }
  .pager__next { grid-column: 1; text-align: left; }
}

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

.foot {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 3.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-faint);
}
.foot p { max-width: 42rem; margin: 0 0 0.5rem; }
.foot a { color: var(--ink-soft); }

/* ------------------------------------------------------------------- katex */

.katex { font-size: 1.04em; }
.katex-display {
  margin: 1.5rem 0;
  padding: 0.9rem 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-sunken);
  border-radius: 8px;
  border: 1px solid var(--rule);
}

/* -------------------------------------------------------------- utilities */

.svg-label { font-family: var(--sans); font-size: 11px; fill: var(--ink-faint); }
.svg-label--strong { fill: var(--ink); font-weight: 600; }
.svg-axis { stroke: var(--rule-strong); stroke-width: 1; }
.svg-grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 3; }
.svg-value { font-family: var(--mono); font-size: 10.5px; fill: var(--ink-soft); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media print {
  .masthead, .rail, .pager, .figure__controls { display: none; }
  .shell { grid-template-columns: 1fr; }
  body { font-size: 11pt; }
}
