:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #17171a;
  --muted: #6d6c70;
  --line: #e3e1da;
  --accent: #d9502b;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1180px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #19191c;
  --ink: #eeede9;
  --muted: #9a9996;
  --line: #2a2a2e;
  --accent: #f0764f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .45s var(--ease), color .45s var(--ease);
}

a { color: inherit; }
img, video, iframe { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }

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

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 20;
}
.skip:focus { left: 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px var(--gutter);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { font: 400 24px/1 var(--serif); text-decoration: none; letter-spacing: 0.01em; }
.slash { color: var(--accent); font-style: italic; padding: 0 1px; }
.site-header nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); }

.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  cursor: pointer; transition: border-color .15s;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle svg { transition: transform .6s var(--ease); }
[data-theme="dark"] .theme-toggle svg { transform: rotate(180deg); }

/* Reading progress along the bottom edge of the header */
.progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--accent);
  transform: scaleX(var(--progress, 0)); transform-origin: left;
}
.site-header nav a { text-decoration: none; font-size: 14px; color: var(--muted); transition: color .15s; }
.site-header nav a:hover { color: var(--ink); }

/* Layout */
main > section, .site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
main > section { padding-top: clamp(56px, 9vw, 112px); }

.eyebrow {
  font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}

/* Hero */
.hero { padding-bottom: clamp(8px, 2vw, 24px); }
.hero h1 {
  font: 400 clamp(44px, 9vw, 104px)/1.02 var(--serif);
  letter-spacing: -0.015em;
  margin: 18px 0 28px;
}
.hero h1 em { color: var(--accent); }

/* Hero: lines slide up out of a mask on load, then drift and fade as you scroll away */
.hero { transform: translateY(calc(var(--drift, 0) * 1px)); opacity: var(--fade, 1); will-change: transform, opacity; }
.hero .line { display: block; overflow: hidden; padding-bottom: .14em; margin-bottom: -.14em; }
.hero .line > span { display: block; }
.js .hero .line > span { animation: line-up 1s var(--ease) backwards; }
.js .hero .line:nth-child(2) > span { animation-delay: .1s; }
.js .hero .line:nth-child(3) > span { animation-delay: .2s; }
.js .hero .eyebrow { animation: fade-up .8s var(--ease) backwards; }
.js .hero .lede { animation: fade-up .9s var(--ease) .45s backwards; }
@keyframes line-up { from { transform: translateY(115%); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } }

/* Scroll reveal: script.js adds .reveal, then .in when the element enters the viewport */
.js .reveal { opacity: 0; transform: translateY(32px); }
.js .reveal.in {
  opacity: 1; transform: none;
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.lede { max-width: 46ch; font-size: clamp(16px, 1.6vw, 19px); color: var(--muted); }

h2 { font: 400 clamp(28px, 4vw, 40px)/1.1 var(--serif); }

/* Work */
.section-head {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px 32px;
  padding-bottom: 24px; margin-bottom: 28px; border-bottom: 1px solid var(--line);
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters button {
  font: 500 13px/1 var(--sans);
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.filters button:hover { color: var(--ink); border-color: var(--muted); }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filters sup { margin-left: 5px; font-size: 10px; opacity: .65; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: clamp(20px, 3vw, 36px) clamp(16px, 2.4vw, 28px);
}
.card { text-decoration: none; display: block; }
.card[hidden] { display: none; }
@media (min-width: 720px) { .card.featured { grid-column: span 2; } .card.featured .cover { aspect-ratio: 2 / 1; } }

.cover {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface);
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s;
}
.card:hover .cover { transform: translateY(-4px); box-shadow: 0 18px 40px -22px rgb(0 0 0 / .35); }

/* Generated cover for projects without an image: a soft two-tone "split". */
.placeholder {
  display: grid; place-items: center;
  background: linear-gradient(115deg,
    hsl(var(--h) 42% 88%) 0 50%,
    hsl(calc(var(--h) + 24) 46% 80%) 50% 100%);
}
.placeholder span { font: italic 400 clamp(40px, 6vw, 64px)/1 var(--serif); color: hsl(var(--h) 30% 28%); opacity: .8; }
[data-theme="dark"] .placeholder { background: linear-gradient(115deg, hsl(var(--h) 22% 20%) 0 50%, hsl(calc(var(--h) + 24) 26% 26%) 50% 100%); }
[data-theme="dark"] .placeholder span { color: hsl(var(--h) 40% 82%); }

.card-text { padding: 14px 2px 0; }
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card h3 { font: 500 17px/1.3 var(--sans); }
.card:hover h3 { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card p { color: var(--muted); font-size: 14.5px; margin-top: 4px; }
.kind { display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }

/* About + contact */
.about, .contact { display: grid; gap: 24px; }
@media (min-width: 820px) { .about, .contact { grid-template-columns: 1fr 2fr; gap: 48px; } .contact > :not(h2) { grid-column: 2; } }
.about-body { display: grid; gap: 20px; max-width: 62ch; }
.big { font: 400 clamp(22px, 3vw, 32px)/1.3 var(--serif); text-wrap: pretty; }
.about-body > p:not(.big) { color: var(--muted); }
.facts { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.facts li { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.facts span { flex: 0 0 90px; color: var(--muted); }

.contact .big a { color: var(--accent); text-underline-offset: 5px; text-decoration-thickness: 1px; overflow-wrap: anywhere; }
.socials { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; padding: 0; font-size: 14.5px; }
.socials a { color: var(--muted); text-underline-offset: 4px; }
.socials a:hover { color: var(--ink); }

/* Footer */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  margin-top: clamp(64px, 10vw, 128px); padding-top: 24px; padding-bottom: 32px;
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* Project view */
.project {
  width: min(880px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink);
  overflow-y: auto; overscroll-behavior: contain;
}
.project::backdrop { background: rgb(10 10 12 / .55); backdrop-filter: blur(4px); }
.project[open] { animation: rise .25s cubic-bezier(.2,.7,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.close {
  position: sticky; top: 12px; float: right; margin: 12px 12px -52px 0; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.close:hover { background: var(--ink); color: var(--surface); }

.media { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); object-fit: cover; }
.project-text { padding: clamp(20px, 4vw, 40px); display: grid; gap: 16px; }
.project-text h2 { font-size: clamp(32px, 5vw, 48px); }
.project-text > p:not(.eyebrow) { max-width: 62ch; color: var(--muted); font-size: 16.5px; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; padding: 0; }
.tags li { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.button {
  text-decoration: none; font-weight: 500; font-size: 14px;
  padding: 11px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  transition: opacity .15s;
}
.button:hover { opacity: .85; }
.gallery { display: grid; gap: 12px; margin-top: 8px; }
.gallery img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .hero { transform: none; opacity: 1; }
}
