/* lionell.dev — a quiet personal site.
   Typography-first, with Tufte-style sidenotes that live in the
   right margin on wide screens and collapse into tap-to-open
   toggles on narrow ones. No frameworks, no build step. */

:root {
  --paper: #faf7f1;
  --ink: #26241f;
  --muted: #7a7365;
  --faint: #a39a87;
  --accent: #9c4a2f;      /* terracotta */
  --accent-soft: #f3e4d8;
  --rule: #e5ddcc;
  --code-bg: #f1ebdd;
  --serif: "Noto Serif", Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1a16;
    --ink: #e8e2d4;
    --muted: #a89e8b;
    --faint: #6e6656;
    --accent: #d08a63;
    --accent-soft: #3a2c22;
    --rule: #38332a;
    --code-bg: #262219;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.7;
  counter-reset: sidenote-counter;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-soft);
}

/* ---------- shell ---------- */

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.prose {
  max-width: 38rem;
}

header.site {
  padding: 2.5rem 0 1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}

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

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

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

nav.site a {
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  margin-left: 1.4rem;
}

nav.site a:hover,
nav.site a.active {
  color: var(--accent);
}

footer.site {
  margin-top: 4rem;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--faint);
  letter-spacing: 0.02em;
}

/* ---------- type ---------- */

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: 2.6rem; margin: 0 0 0.6rem; }
h2 { font-size: 1.6rem; margin: 2.5rem 0 0.8rem; }
h3 { font-size: 1.25rem; margin: 2rem 0 0.6rem; }

.lede {
  font-size: 1.35rem;
  line-height: 1.55;
  color: var(--muted);
}

.byline {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--faint);
  letter-spacing: 0.04em;
  margin-bottom: 2rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

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

p { margin: 0 0 1.2em; }

blockquote {
  margin: 1.6em 0;
  padding-left: 1.2em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

pre {
  background: var(--code-bg);
  padding: 1.1rem 1.3rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
}

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

ul.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.post-list li {
  display: flex;
  gap: 1.2rem;
  align-items: baseline;
  padding: 0.7rem 0;
  border-bottom: 1px dotted var(--rule);
}

ul.post-list .date {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--faint);
  white-space: nowrap;
  min-width: 6.5rem;
}

ul.post-list a.title {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
}

ul.post-list a.title:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* ---------- sidenotes ---------- */

.sidenote-number {
  counter-increment: sidenote-counter;
  cursor: pointer;
}

.sidenote-number::after {
  content: counter(sidenote-counter);
  font-size: 0.72em;
  font-weight: 600;
  color: var(--accent);
  vertical-align: super;
  line-height: 0;
  padding-left: 0.1em;
}

input.margin-toggle { display: none; }

.sidenote {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

.sidenote::before {
  content: counter(sidenote-counter) ". ";
  color: var(--accent);
  font-weight: 600;
}

/* wide screens: notes float in the right margin */
@media (min-width: 68rem) {
  .sidenote-number { cursor: default; }

  .sidenote {
    float: right;
    clear: right;
    width: 15rem;
    margin-right: -18rem;
    margin-top: 0.3rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--rule);
    vertical-align: baseline;
    position: relative;
  }
}

/* narrow screens: notes collapse into tap-to-open blocks */
@media (max-width: 67.999rem) {
  .sidenote { display: none; }

  .margin-toggle:checked + .sidenote {
    display: block;
    float: none;
    width: 100%;
    margin: 0.9rem 0;
    padding: 0.9rem 1.1rem;
    background: var(--accent-soft);
    border-radius: 8px;
    border-left: none;
  }

  .sidenote-number::after {
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 0 0.35em 0.05em 0.45em;
    margin-left: 0.15em;
  }
}

/* ---------- odds and ends ---------- */

img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

figure { margin: 1.8em 0; }
figcaption {
  font-size: 0.85rem;
  color: var(--faint);
  margin-top: 0.5rem;
  font-family: var(--sans);
}

.hero-hello {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 1.5rem 0 1rem;
}

.hero-hello .dot { color: var(--accent); }

@media (max-width: 40rem) {
  body { font-size: 1.05rem; }
  h1 { font-size: 2rem; }
  ul.post-list li { flex-direction: column; gap: 0.15rem; }
}
