/* Elijah's World — hand-written styles. No build step: edit and refresh. */

/* ───────── Tokens ───────── */
:root {
  --paper: #f3efe6;
  --paper-2: #e9e3d6;
  --ink: #16150f;
  --muted: #5d584c;
  --line: rgba(22, 21, 15, 0.22);
  --accent: #2445e8;
  --accent-deep: #13258f;   /* gradient end; also button hover in light mode */
  --accent-hover: #13258f;  /* button hover: darker in light mode, lighter in dark mode */
  --on-accent: #ffffff;
  --fail: #a3261f;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* spacing: small / medium / large */
  --space-1: 12px;
  --space-2: 24px;
  --space-3: clamp(40px, 6vw, 72px);
  /* type: display sizes share one line-height rhythm */
  --fs-h1: clamp(2.8rem, 7vw, 5.2rem);
  --fs-h2: clamp(2rem, 4.2vw, 3.2rem);
  --fs-h3: clamp(1.6rem, 2.8vw, 2.1rem);

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #100f0b; --paper-2: #1a1913; --ink: #efeadf; --muted: #a29d90;
    --line: rgba(239, 234, 223, 0.13);
    --accent: #5b78ff; --accent-deep: #2a3fc4; --accent-hover: #8aa0ff;
    --on-accent: #0a0b12; --fail: #ff8f86;
    color-scheme: dark;
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; background: var(--ink); color: var(--paper);
  border-radius: 8px; text-decoration: none; transition: top .15s;
}
.skip:focus { top: 12px; }

.eyebrow {
  font: 500 12px/1.2 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ───────── Header ───────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: -0.01em; }
.wordmark-mark {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 999px 999px 6px 6px;
  background: var(--accent); color: var(--on-accent);
  font: italic 400 20px/1 var(--serif);
}
.nav { display: flex; gap: clamp(14px, 3vw, 32px); }
.nav a {
  display: block; white-space: nowrap;
  text-decoration: none; font-size: 15px; color: var(--muted);
  padding: 10px 0; border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav a:hover, .nav a[aria-current] { color: var(--ink); border-color: var(--ink); }
.nav a[aria-current] { border-color: var(--accent); }

/* ───────── Hero ───────── */
.hero { padding: clamp(20px, 3vw, 36px) 0 clamp(24px, 3vw, 32px); }
.hero + .section { padding-top: clamp(32px, 4vw, 44px); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  align-items: end;
  gap: clamp(32px, 6vw, 80px);
}
.hero-copy { display: grid; gap: 18px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(3rem, 6vw, 5rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { max-width: 38ch; font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* By the numbers: every figure comes from the model READMEs, backtests and the server page */
.stats { margin: 6px 0 0; padding-top: 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
.stats dt { font: 400 clamp(1.9rem, 3.2vw, 2.6rem)/1 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.stats dd { margin: 6px 0 0; font: 400 12px/1.4 var(--mono); color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 22px;
  border-radius: 999px; text-decoration: none;
  font-weight: 500; font-size: 15px;
  transition: transform .15s ease, background .15s, color .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-deep); color: #fff; }
.btn-ghost { border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); }
.btn-ghost:hover { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--ink) 12%, transparent); }

/* Portrait: photo rising out of a soft, grainy arch; the photo's hard bottom edge fades into it */
.portrait { position: relative; margin: 0; padding-top: 12%; isolation: isolate; max-width: 380px; justify-self: end; width: 100%; }
.arch {
  position: absolute; inset: 22% 0 0 0; z-index: -1;
  border-radius: 999px 999px var(--radius) var(--radius);
  --arch-a: color-mix(in srgb, var(--accent) 42%, var(--paper-2));
  --arch-b: color-mix(in srgb, var(--accent-deep) 55%, var(--paper-2));
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 160px,
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--arch-a) 70%, white) 0%, transparent 62%),
    linear-gradient(180deg, var(--arch-a) 0%, var(--arch-b) 100%);
  background-blend-mode: soft-light, normal, normal;
}
.portrait img {
  width: 100%;
  -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent 99%);
  mask-image: linear-gradient(180deg, #000 78%, transparent 99%);
}

/* ───────── Sections ───────── */
.section { padding: clamp(48px, 6vw, 88px) 0; border-top: 1px solid var(--line); }
.section-head { display: grid; gap: var(--space-1); margin-bottom: var(--space-3); }
.section h2 {
  font-family: var(--serif);
  font-size: var(--fs-h2);
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(24px, 6vw, 96px);
  align-items: start;
}
.split .section-head { margin-bottom: var(--space-2); }
.prose { display: grid; gap: 20px; font-size: clamp(1.05rem, 1.5vw, 1.2rem); }

/* Projects: a grid of cards; the whole card is clickable through the link's ::after.
   On wide screens each card is a subgrid so asides, tags and links line up across a row. */
.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.project {
  position: relative; display: flex; flex-direction: column; gap: var(--space-1);
  padding: clamp(22px, 3vw, 34px);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, transform .15s, box-shadow .2s;
}
@supports (grid-template-rows: subgrid) {
  .project { display: grid; grid-row: span 6; grid-template-rows: subgrid; row-gap: var(--space-1); }
}
.project:hover, .project:focus-within { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 28px -12px color-mix(in srgb, var(--accent) 55%, transparent); }
.project-num { font: 500 13px/1 var(--mono); color: var(--accent); }
.project h3 { font-family: var(--serif); font-size: var(--fs-h3); line-height: 1.05; }
.project p { color: var(--muted); }
.project .aside { color: var(--ink); padding-left: 14px; border-left: 2px solid var(--accent); }
.tags { display: flex; flex-wrap: wrap; align-content: start; gap: 8px; }
.tags li {
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  font: 400 12px/1.2 var(--mono); color: var(--muted);
}
.project-link {
  margin-top: auto; padding-top: 6px; align-self: end; justify-self: start;
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500; font-size: 15px; color: var(--accent); text-decoration: none;
}
.project-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.project-link:focus-visible { outline: none; }
.project:has(.project-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.project-link span { transition: transform .15s; }
.project:hover .project-link span { transform: translateX(3px); }
.more { margin-top: 28px; color: var(--muted); }
.more a { color: var(--accent); text-underline-offset: 3px; }

/* Contact (sits beside About) */
.contact { padding: clamp(22px, 3vw, 34px); background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: var(--space-1); align-self: start; }
.contact h3 { font-family: var(--serif); font-size: var(--fs-h3); line-height: 1.05; }
.contact-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; font-size: clamp(1.05rem, 1.8vw, 1.3rem); }
.contact-email {
  text-decoration: none; overflow-wrap: anywhere;
  border-bottom: 2px solid var(--accent); padding-bottom: 2px;
  transition: color .15s;
}
.contact-email:hover { color: var(--accent); }
.contact-email span { font-size: 0.8em; color: var(--accent); }
.copy-email {
  min-height: 36px; padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); border-radius: 999px;
  background: transparent; color: var(--ink);
  font: 500 13px/1 var(--mono); letter-spacing: 0.02em;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.copy-email:hover { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.copy-email:active { background: color-mix(in srgb, var(--ink) 14%, transparent); }
.copy-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ───────── Subpages (lab notes, server, project) ───────── */
.page-head { padding: var(--space-3) 0 var(--space-2); display: grid; gap: 18px; }
.page-head h1 { font-family: var(--serif); font-size: var(--fs-h1); line-height: 0.96; letter-spacing: -0.02em; text-wrap: balance; }
.page-head h1 em { font-style: italic; color: var(--accent); }
.page-head .lede { max-width: 52ch; }
.page-body { padding-bottom: var(--space-3); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
/* each section: sticky heading on the left, content on the right */
.page-body > section { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--space-2) clamp(24px, 5vw, 72px); padding-top: var(--space-3); border-top: 1px solid var(--line); align-items: start; }
.page-body h2 { font-family: var(--serif); font-weight: 400; font-size: var(--fs-h2); line-height: 1.05; letter-spacing: -0.015em; position: sticky; top: 96px; }
.page-body p + p { margin-top: 14px; }
.measure { max-width: 66ch; }
.page-body a:not(.btn) { color: var(--accent); text-underline-offset: 3px; }
.page-body a:not(.btn):hover { text-decoration-thickness: 2px; }
.crumb { font: 500 12px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
code { font: 400 0.88em var(--mono); padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper-2); overflow-wrap: anywhere; }
.num { font-family: var(--mono); font-size: 0.92em; }
.callout { padding: 18px 22px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--paper-2); }
.note { margin-top: 18px; }

/* Lab notes: one entry per question */
.entry { padding: clamp(24px, 3.5vw, 36px) 0; border-bottom: 1px solid var(--line); }
.entry:first-child { padding-top: 0; }
.verdict { display: inline-block; margin-bottom: 14px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font: 500 12px/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.verdict.fail { border-color: var(--fail); color: var(--fail); }
.verdict.open { border-color: var(--accent); color: var(--accent); }
.entry h3 { font-family: var(--serif); font-weight: 400; font-size: var(--fs-h3); line-height: 1.1; margin-bottom: 14px; }
.entry dl { margin: 0; display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 16px; max-width: 70ch; }
.entry dt { font: 500 12px/1.9 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.entry dd { margin: 0; }
.quick { display: grid; gap: 10px; max-width: 70ch; list-style: disc; padding-left: 1.2em; }
.quick li::marker { color: var(--accent); }

/* Server page */
.rules { margin: 14px 0; display: grid; gap: 10px; max-width: 66ch; list-style: decimal; padding-left: 1.3em; }
.rules li::marker { color: var(--accent); font-family: var(--mono); }
.flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; counter-reset: step; }
.flow li { counter-increment: step; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); }
.flow li::before { content: "0" counter(step); display: block; margin-bottom: 10px; font: 500 12px/1 var(--mono); color: var(--accent); }
.flow strong { display: block; margin-bottom: 4px; }
.flow span { color: var(--muted); font-size: 0.95rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap:focus-visible { outline-offset: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { font: 500 12px/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
td:first-child { white-space: nowrap; font-family: var(--mono); font-size: 0.9em; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* 404 */
.lost { min-height: 60vh; display: grid; align-content: center; gap: var(--space-2); padding-block: 64px; }
.lost .numeral { font: 400 clamp(5rem, 22vw, 14rem)/0.85 var(--serif); letter-spacing: -0.03em; color: var(--accent); }
.lost h1 { font-family: var(--serif); font-size: var(--fs-h2); line-height: 1.05; }

/* ───────── Footer ───────── */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; }
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  font: 400 13px/1.5 var(--mono); color: var(--muted);
}

/* ───────── Responsive ───────── */
@media (max-width: 900px) {
  .split, .page-body > section { grid-template-columns: minmax(0, 1fr); }
  .page-body h2 { position: static; }
}
@media (min-width: 901px) { .flow { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  body { font-size: 16px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-grid { gap: 18px; }
  .hero-copy { display: contents; }
  .portrait { max-width: 230px; width: 62%; margin: 4px auto 0; justify-self: center; }
  .stats { order: 1; }
  .stats dd { font-size: 11px; }
  .projects { grid-template-columns: 1fr; }
  .project { display: flex; grid-row: auto; }
  .nav { gap: 16px; }
  .nav a { font-size: 14px; }
}
@media (max-width: 480px) {
  .wordmark > span:last-child { display: none; }
  .entry dl { grid-template-columns: 1fr; gap: 2px; }
  .entry dd { margin-bottom: 10px; }
}
/* Narrow phones: wordmark on one row, nav on its own row, so five links never overflow */
@media (max-width: 400px) {
  html { scroll-padding-top: 120px; }
  .wordmark > span:last-child { display: inline; }
  .header-inner { flex-wrap: wrap; height: auto; padding-block: 6px 0; gap: 0 16px; }
  nav { width: 100%; }
  .nav { justify-content: space-between; gap: 6px; }
  .nav a { font-size: 13px; padding: 12px 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .btn:hover, .btn:active, .project:hover, .project:focus-within { transform: none; }
}
