/* =========================================================
   Oliver Grainge — site styles
   Editorial / minimal. Plain CSS, no build step.
   ========================================================= */

:root {
  --bg: #f7f5f0;
  --bg-raised: #fffdf8;
  --ink: #161614;
  --muted: #5f5d57;
  --faint: #8d8a82;
  --rule: #dedad0;
  --accent: #b4441f;
  --accent-soft: rgba(180, 68, 31, 0.08);
  --code-bg: #eeebe3;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --wrap: 1080px;
  --wrap-narrow: 720px;
  --gutter: 24px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --bg-raised: #1b1b19;
    --ink: #ecebe6;
    --muted: #a8a59c;
    --faint: #7a776f;
    --rule: #2e2d29;
    --accent: #ec8a62;
    --accent-soft: rgba(236, 138, 98, 0.1);
    --code-bg: #22221f;
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.2em; transition: color .15s, text-decoration-color .15s; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

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

.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: var(--gutter); top: 12px; background: var(--ink); color: var(--bg); padding: 6px 12px; z-index: 10; }

.eyebrow, .label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.eyebrow:has(> span) { display: flex; flex-wrap: wrap; }
.eyebrow span + span::before { content: "·"; margin: 0 .6em; color: var(--faint); }

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

.site-header {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.site-header__name { font-family: var(--serif); font-size: 22px; text-decoration: none; letter-spacing: -0.01em; }
.site-nav { display: flex; gap: 28px; }
.site-nav a { font-size: 15px; text-decoration: none; color: var(--muted); }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--ink); }

.site-footer { border-top: 1px solid var(--rule); margin-top: 96px; }
.site-footer__inner { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; padding-top: 28px; padding-bottom: 40px; font-size: 14px; color: var(--muted); }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 20px; }
.site-footer a { text-decoration: none; }

/* ---------- Home: hero ---------- */

.hero { padding-top: clamp(48px, 9vw, 120px); padding-bottom: clamp(48px, 7vw, 88px); }
.hero__grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 56px; align-items: end; }
.hero__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.7rem, 6.6vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 20px 0 28px;
  max-width: 13em;
}
.hero__title em { color: var(--accent); }
.hero__lede { font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--muted); max-width: 36em; margin: 0; }
.hero__lede strong { color: var(--ink); font-weight: 500; }

.hero__portrait { width: 200px; margin: 0; }
.hero__portrait img {
  width: 200px; height: 250px; object-fit: cover; object-position: 50% 25%;
  border-radius: 4px; filter: grayscale(1) contrast(1.05);
  transition: filter .4s ease;
}
.hero__portrait:hover img { filter: none; }
.hero__portrait figcaption { margin-top: 10px; }

.link-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 36px; padding: 0; list-style: none; }
.pill-link {
  display: inline-flex; align-items: center; gap: .4em;
  padding: 7px 14px; border: 1px solid var(--rule); border-radius: 999px;
  font-size: 14px; text-decoration: none; background: var(--bg-raised);
  transition: border-color .15s, color .15s, background .15s;
}
.pill-link:hover { border-color: var(--accent); color: var(--accent); }
.pill-link--solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill-link--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* ---------- Home: figures strip ---------- */

.figures {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  margin: 0; padding: 0; list-style: none;
}
.figures li { padding: 28px 24px 28px 0; }
.figures li + li { padding-left: 24px; border-left: 1px solid var(--rule); }
.figures__num { display: block; font-family: var(--serif); font-size: clamp(2.4rem, 4.5vw, 3.4rem); line-height: 1; letter-spacing: -0.02em; }
.figures__what { display: block; margin-top: 10px; font-size: 14px; color: var(--muted); line-height: 1.45; }

/* ---------- Home: sections ---------- */

.section {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px;
  padding: 64px 0; border-bottom: 1px solid var(--rule);
}
.section:last-of-type { border-bottom: 0; }
.section__label { position: sticky; top: 96px; align-self: start; }
.section__label .num { display: block; font-family: var(--mono); font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.section__label h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
.section__more { display: inline-block; margin-top: 28px; font-size: 15px; }

/* Work list */
.work-list { list-style: none; margin: 0; padding: 0; }
.work-item a {
  display: grid; grid-template-columns: minmax(0, 1fr) 176px; gap: 32px; align-items: center;
  padding: 26px 0; text-decoration: none; border-top: 1px solid var(--rule);
}
.work-item:first-child a { border-top: 0; padding-top: 0; }
.work-item__title { font-family: var(--serif); font-size: 30px; line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.01em; transition: color .15s; }
.work-item__title .arrow { display: inline-block; font-family: var(--sans); font-size: 20px; margin-left: 8px; transition: transform .2s ease; color: var(--faint); }
.work-item__desc { color: var(--muted); margin: 0 0 12px; font-size: 16px; }
.work-item__thumb { aspect-ratio: 16 / 10; overflow: hidden; border-radius: 4px; border: 1px solid var(--rule); background: #fff; }
.work-item__thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.work-item a:hover .work-item__title { color: var(--accent); }
.work-item a:hover .arrow { transform: translateX(4px); color: var(--accent); }
.work-item a:hover .work-item__thumb img { transform: scale(1.04); }

/* Experience */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 24px; padding: 22px 0; border-top: 1px solid var(--rule); }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline__date { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 4px; }
.timeline__role { font-weight: 600; margin: 0; }
.timeline__org { color: var(--muted); margin: 0 0 8px; }
.timeline__desc { margin: 0; font-size: 16px; }

/* Publications (home + page) */
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { padding: 22px 0; border-top: 1px solid var(--rule); }
.pub:first-child { border-top: 0; padding-top: 0; }
.pub__title { font-family: var(--serif); font-size: 24px; line-height: 1.2; margin: 0 0 8px; font-weight: 400; letter-spacing: -0.005em; }
.pub__title a { text-decoration: none; }
.pub__meta { margin: 0; }
.pub__meta .venue { color: var(--accent); }
.pub__note { margin: 8px 0 0; color: var(--muted); font-size: 16px; }

/* Toolkit */
.toolkit { margin: 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px 24px; }
.toolkit dt { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 3px; }
.toolkit dd { margin: 0; }

/* Education */
.edu { margin: 0 0 20px; }
.edu:last-child { margin-bottom: 0; }
.edu__degree { font-weight: 600; margin: 0; }
.edu__meta { color: var(--muted); margin: 0; }

/* Contact */
.contact { padding: clamp(64px, 10vw, 120px) 0 0; text-align: left; }
.contact__title { font-family: var(--serif); font-weight: 400; font-size: clamp(2.4rem, 5.5vw, 4.4rem); line-height: 1.05; letter-spacing: -0.02em; margin: 16px 0 28px; max-width: 14em; }
.contact__title a { text-decoration: none; color: var(--accent); border-bottom: 2px solid currentColor; }
.contact__title a:hover { color: var(--ink); }

/* ---------- Generic page (archive layout) ---------- */

.page__header { padding: clamp(48px, 8vw, 96px) 0 40px; border-bottom: 1px solid var(--rule); margin-bottom: 48px; }
.page__title { font-family: var(--serif); font-weight: 400; font-size: clamp(2.8rem, 7vw, 5rem); line-height: 1; letter-spacing: -0.025em; margin: 0; }
.page__intro { color: var(--muted); font-size: 1.15rem; max-width: 36em; margin: 20px 0 0; }

/* Portfolio grid */
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 56px 40px; }
.card { text-decoration: none; display: block; }
.card__image { aspect-ratio: 16 / 10; overflow: hidden; border-radius: 4px; border: 1px solid var(--rule); background: #fff; margin-bottom: 18px; }
.card__image img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card:hover .card__image img { transform: scale(1.03); }
.card__title { font-family: var(--serif); font-size: 28px; line-height: 1.12; margin: 10px 0 8px; font-weight: 400; letter-spacing: -0.01em; transition: color .15s; }
.card__title small { display: block; font-size: 0.68em; color: var(--muted); margin-top: 4px; }
.card__excerpt { color: var(--muted); margin: 0; font-size: 16px; }
.card:hover .card__title { color: var(--accent); }

.pub-group + .pub-group { margin-top: 64px; }
.pub-group > h2 { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 400; margin: 0 0 24px; }

/* ---------- Article (single layout) ---------- */

.article__header { padding: clamp(40px, 7vw, 80px) 0 40px; }
.back-link { display: inline-block; font-size: 14px; color: var(--muted); text-decoration: none; margin-bottom: 36px; }
.article__title { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 6vw, 4.2rem); line-height: 1.02; letter-spacing: -0.02em; margin: 18px 0 0; }
.article__subtitle { display: block; font-size: 0.5em; line-height: 1.2; color: var(--muted); margin-top: 12px; letter-spacing: -0.005em; }
.article__dek { font-size: 1.2rem; color: var(--muted); margin: 24px 0 0; }
.article__actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0 0; }

.prose { border-top: 1px solid var(--rule); padding-top: 40px; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-family: var(--serif); font-weight: 400; font-size: 2rem; line-height: 1.15; letter-spacing: -0.01em; margin: 2.2em 0 .5em; }
.prose h3 { font-size: 1.1rem; font-weight: 600; margin: 2em 0 .5em; }
.prose h4 { font-size: 1rem; font-weight: 600; margin: 1.6em 0 .4em; }
.prose p, .prose ul, .prose ol, .prose table, .prose pre, .prose blockquote { margin: 0 0 1.2em; }
.prose a { text-decoration-color: var(--accent); }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--faint); }
.prose strong { font-weight: 600; }
.prose img { border-radius: 4px; border: 1px solid var(--rule); background: #fff; margin: 2em auto .75em; }
.prose img.wide { width: min(980px, calc(100vw - 2 * var(--gutter))); max-width: none; margin-left: 50%; transform: translateX(-50%); }
.prose p > img ~ em, .prose p:has(> img) + p > em:only-child { display: block; font-style: normal; font-size: 14px; color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
.prose blockquote { border-left: 2px solid var(--accent); padding-left: 1.2em; color: var(--muted); }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .12em .35em; border-radius: 3px; }
.prose pre { background: var(--code-bg); padding: 18px 20px; border-radius: 4px; overflow-x: auto; font-size: 14px; line-height: 1.55; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 10px 14px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 400; }

.citation { margin-top: 56px; padding: 22px 24px; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 4px; font-size: 15px; }
.citation p:last-child { margin: 8px 0 0; }

/* Syntax highlighting (rouge), kept minimal */
.highlight .c, .highlight .c1, .highlight .cm { color: var(--faint); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kt { color: var(--accent); }
.highlight .s, .highlight .s1, .highlight .s2 { color: #5a7a3a; }
.highlight .mi, .highlight .mf { color: #3a6a8a; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .section { grid-template-columns: 1fr; gap: 28px; padding: 48px 0; }
  .section__label { position: static; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figures li:nth-child(3) { padding-left: 0; border-left: 0; }
  .figures li:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .card-grid { grid-template-columns: 1fr; gap: 48px; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .site-nav { gap: 18px; }
  .hero__grid { grid-template-columns: 1fr; gap: 32px; }
  .hero__portrait { order: -1; width: 96px; }
  .hero__portrait img { width: 96px; height: 96px; border-radius: 50%; }
  .hero__portrait figcaption { display: none; }
  .work-item a { grid-template-columns: 1fr; gap: 16px; }
  .work-item__thumb { order: -1; }
  .work-item__title { font-size: 26px; }
  .timeline li { grid-template-columns: 1fr; gap: 4px; }
  .toolkit { grid-template-columns: 1fr; gap: 4px; }
  .toolkit dd { margin-bottom: 12px; }
  .figures li { padding: 22px 12px 22px 0; }
  .figures li + li { padding-left: 12px; }
}

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